Box2D Forums

It is currently Sun May 19, 2013 2:46 am

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Moving Bodies.
PostPosted: Fri Feb 18, 2011 11:25 am 
Offline

Joined: Mon Jul 12, 2010 2:15 am
Posts: 47
Well I assumed I'd be able to move an object using the x and y of the MovieClip and the body would follow it. Looking at the draw debug I see I'm wrong.

So how would I move an object without setting it's velocity? Like I'm trying to make moving platforms(not tweened) and I need the body to move with it. I can do this by calling destroy() the create() every frame but I'd image there probably a much more efficient way to do this.

EDIT: I also see the that platforms don't follow you. I'm guessing I'm dealing with all of this the wrong way.


Top
 Profile  
 
 Post subject: Re: Moving Bodies.
PostPosted: Fri Feb 18, 2011 1:14 pm 
Offline

Joined: Fri Dec 14, 2007 8:07 pm
Posts: 913
set the type of the body to "Animated". Then you should be able to set the x and y.


Top
 Profile  
 
 Post subject: Re: Moving Bodies.
PostPosted: Fri Feb 18, 2011 1:55 pm 
Offline

Joined: Mon Jul 12, 2010 2:15 am
Posts: 47
Ok thanks.

EDIT: Wait, so I would guess this would work the same for rotation. What if I want to change the rotation on the player and the player is added in code, but I can't seem to use b2body.SetType(3)

I'm trying to make a rotation limit, if there's maybe a better way.

EDIT 2: There was. >.<

Code:
if (rotation > 80) b2body.SetAngularVelocity( -b2body.GetMass() * 25);
if (rotation < -80) b2body.SetAngularVelocity(b2body.GetMass() * 25);


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 5 guests


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

Search for:
Powered by phpBB® Forum Software © phpBB Group