Jump to content
  • Advertisement
Sign in to follow this  
furrymaster

[Box2D]Problem with joints - simple moving

This topic is 2587 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I`m writting because i have problem with using joints in Box2D. I`m trying to create simple moving system for my units but i cannot find out how to move units with this and this speed. I was trying to use linear Velocity but i have to control when units are on place in which i want them. I`ve tried joints but they are working like a... gum? U know, at start they move slow but if they are closer to target position my unit moves faster.
Can u give me an advice how to use joints to have an effect like i want? (i was looking for good tutorial about this but all are with jumping boxes, moving them with mouse or car with wheels:( )

Share this post


Link to post
Share on other sites
Advertisement
Try to search for "kinematic" bodies. The documentation advises to move the by setting their velocity, but that's not very hard to adapt to follow a position path.

Share this post


Link to post
Share on other sites
But when i setting their velocity i`ll have to control when to stop them because this is force vector, so when they reach my target they will still keep moving.

Share this post


Link to post
Share on other sites
It is not a "force vector", just the velocity. But like a manual force, you have to recalculate the value at each step. So for example when the target is reached, you just set the velocity to 0.

Share this post


Link to post
Share on other sites
thank you i ll try to use it.

Edit:
kinematics are bad idea because i need colisions, sometimes joints etc.
And still i dont know WHEN to stop moving object.
If i do sth like this:

Vector_2D range=pos - target;
range=range*range;
if(range.x+range.y < 10)
stop();

my body can still keep moving if it colide with something in its way.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!