Morning :)
I try to build a velocity vector like b2Vec2 (guess that should be correct., at least it's the vectortype from c++). How do i manage that with javascript? I try to move an object continuously, but it should still cause collision events. I set the worlds gravity to 0 and I guess that I need to set a linear velocity by using a velocity vector right? That object shall not accelerate or decelerate.
Is there any kind of helpful information or is there any documentation, that may help with these kind of physics?
thanks in advance for your help :)
1 Answer
Accepted Answer
You're right, you need to set the gravity to zero and update the linear velocity of each body. This should be done every "tick" or "step". Unfortunately no callback is provided for ticks in the module, but you can try something like:
setTimeout(function() { bodyRef.setLinearVelocity(0, 5); // Move vertically with no forces applied }, 1000 / 60); // Call at 60 frames per secondSee: http://www.iforce2d.net/b2dtut/constant-speed
Your Answer
Think you can help? Login to answer this question!