Moving an object using its velocity on a closed curve

Posted by Futaro on Game Development See other posts from Game Development or by Futaro
Published on 2012-06-11T04:45:33Z Indexed on 2012/06/11 16:49 UTC
Read the original article Hit count: 199

Filed under:

I want that an object follows a path, in Peggle game there are some pegs that have movement in a closed path. How can i get the same result? I guess that I can use parametric curve but I need use the velocity and not the position (x, y).

I use NAPE and I have this in my gameloop:
//circunference
angle = angle + 1*(Math.PI / 180);
movableBall.position.x = radius * Math.cos(angle)+ h;
movableBall.position.y = radius * Math.sin(angle)+ k;

it's works but I can not control the velocity, each movableBall must have its own velocity. Besides, from docs of NAPE:"Setting the position of a body is equivalent to simply teleporting the body; for instance moving a kinematic body by position is not the way to go about things.."
I want to use:
movableBall.velocity.x =??
movableBall.velocity.y = ??

The final idea is to follow others paths like the Lemniscate of Bernoulli. Thanks!

© Game Development or respective owner

Related posts about curves