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

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

Recommended Posts

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.

Share on other sites
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 :)

Share on other sites

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

Regards.

Share on other sites
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.

1. 1
Rutin
42
2. 2
3. 3
4. 4
5. 5

• 9
• 27
• 20
• 14
• 14
• Forum Statistics

• Total Topics
633388
• Total Posts
3011620
• Who's Online (See full list)

There are no registered users currently online

×