How to control speed of object move along a bezier curve path.

Started by
2 comments, last by ghosted 18 years, 8 months ago
I'm making a 2D vertical scroll shooting game and want an ememie's ship to follow a bezier curve path. The problem is the framework I'm using is use frame base' animation so I don't have any idea how to move a ship along the path with same speed. I've searched over internet and found nothing usefull. Anybody here can guide me to the righ solution, algorithm, source code or something. I would appreciate you help. Sorry for my bad english. Regards.
Advertisement
Likely you have a combination of two related problems.

firstly as you know frame-based movement doesn't offer constant speed movement, the better way is to use time-based movement, there are plenty of resources about this.
Basically rather than moving X units each frame, instead move X units each second -> Find the time passed since the previous frame and the current one (in seconds), multiply that value by the amount you wish to move (time_passed * velocity).
You can easily accommodate accelleration too, but like I said plenty of resources available.

Secondly with bezier curves you typically don't get constant speed, often the animation will slow down on the curvier parts and speed up on the straighter parts. To fix this you need to re-integrate to t, where t is time.
There is loads of info on the net but I recommend you begin by searching the forums here a GDNet.

Hope that was some help :)
Thank you for your quick and kindly reply, dmatter.

I'll try the way your suggestions tonight when I got home and will be here again to post a progress.

Regards.
Actually, frame-based movement will be constant IF you ensure you have a fixed time step but it's pretty much beside the point - 'time based movement' is the way to go. There is an article right here on Gamedev to help with achieving that.

This topic is closed to new replies.

Advertisement