Box2D Forums

It is currently Wed May 22, 2013 9:19 pm

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Fri May 04, 2012 8:11 am 
Offline

Joined: Mon May 11, 2009 4:03 pm
Posts: 8
Hi! I'm looking for some help in mixing my own movement logic with Box2Ds movement. Specifically, while the majority of my game objects would, say, bounce from a collision, some might move on a predetermined path, or be controlled by the mouse. If I manually set the position and velocity of an object, after doing some math to get its position based on whatever controls it, and then call step(), the object would move again, according to Box2Ds idea of where it should go, right? Will adjusting the position and velocity of an object mess with the underlying space partitioning? Will Box2D undo my work when it step()s?

Alternatively, can I do all my own motion and just use the collision detection that Box2D provides?


Top
 Profile  
 
PostPosted: Thu Jun 14, 2012 1:08 pm 
Offline

Joined: Mon May 11, 2009 4:03 pm
Posts: 8
bump


Top
 Profile  
 
PostPosted: Fri Jun 15, 2012 8:12 am 
Offline

Joined: Fri Dec 14, 2007 8:07 pm
Posts: 913
Use kinematic bodies. With type = kinematic (as opposed to static or dynamic) you set the velocity manually. So if you want to move your object from x1, y1 to x2, y2 it's pretty easy to figure out the velocity as x2 - x1, y2 - y1 and set that every timestep.

This is how it works in the WCK port. If you look at the demos you'll see a lot of pre-programmed/animated movement combined with Box2D physics:

http://www.sideroller.com/wck/


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: Google [Bot] and 3 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