# Box2D Forums

 It is currently Thu May 23, 2013 11:16 pm

 All times are UTC - 8 hours [ DST ]

 Page 1 of 1 [ 4 posts ]
 Print view Previous topic | Next topic
Author Message
 Post subject: Rotating upon collisonPosted: Tue May 08, 2012 3:46 pm

Joined: Wed May 18, 2011 1:23 pm
Posts: 8
I'm shooting fireballs which have a tail and I want them to rotate when they bounce off objects. I tried to change their rotation on END_CONTACT but it won't let you alter its rotation once it's moving and I read this messes up the events. Now I'm destroying them on collision and recreating new ones that are rotated the correct direction. This mostly works but sometimes crashes my game. I assume there is a much easier way. Anyone have any ideas?

Top

 Post subject: Re: Rotating upon collisonPosted: Wed May 09, 2012 1:59 am

Joined: Tue Jun 24, 2008 8:25 pm
Posts: 1517
Location: Tokyo
Does it really matter what rotation the physics body itself has?
Could you just draw the fireball in the appropriate angle based on the current direction of movement?

Top

 Post subject: Re: Rotating upon collisonPosted: Wed May 09, 2012 8:00 am

Joined: Wed May 18, 2011 1:23 pm
Posts: 8
That's what I tried to do. I did fireball.rotation = new trajectory but the engine wouldn't let it work. I can only change the rotation before the object is working in the physics world. Once it's bouncing around, changing the rotation doesn't have any effect. I also read a post by they guy that created Box2d saying that changing the rotation in this way would mess up the events of Box2d. What am I missing?

Top

 Post subject: Re: Rotating upon collisonPosted: Thu May 10, 2012 2:41 pm

Joined: Fri Dec 14, 2007 8:07 pm
Posts: 913
That wont work because WCK sets the rotation of the movieclip each frame to the rotation of the b2body. You actually have to rotate the b2body:
Code:
b2body.SetTransform(b2body.GetPosition(), 60 /* <-- angle */);

If this doesn't work inside of your contact event listener, try changing it after the timestep.

Top

 Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending
 Page 1 of 1 [ 4 posts ]

 All times are UTC - 8 hours [ DST ]

#### Who is online

Users browsing this forum: No registered users and 1 guest

 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum

 Search for: