Box2D Forums

It is currently Sun Apr 20, 2014 7:16 pm

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: moving a body
PostPosted: Sun Sep 25, 2011 11:06 am 
Offline

Joined: Sun Sep 25, 2011 10:31 am
Posts: 2
I've found a few references to calling SetXForm() to move a body around, but I can't get this to work with box2dweb

body.SetXForm(new Box2D.Common.Math.b2Vec2( 7,3 , body.GetWorldCenter() ) );

or

body.SetXForm(new Box2D.Common.Math.b2Vec2( 7,3 ) );

Will both throw a TypeError exception.

Anyone have working example of how to do this?

Thanks.


Top
 Profile  
 
 Post subject: Re: moving a body
PostPosted: Tue Sep 27, 2011 9:00 pm 
Offline

Joined: Sun Sep 25, 2011 10:31 am
Posts: 2
well, I've found an extremely hacky workaround:

Box2D.Dynamics.b2World.DestroyBody(aBody);

Then just immediately re-create it somewhere else. Inefficient, but it works.

Would still love to see the proper way to do this.


Top
 Profile  
 
 Post subject: Re: moving a body
PostPosted: Mon Feb 20, 2012 10:22 pm 
Offline

Joined: Mon Feb 20, 2012 2:03 pm
Posts: 14
You are trying to teleport the player/object right? This works for me.

player.SetPosition (new b2Vec2(x,y) )

It's the box2dweb version btw.


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 2 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