Jump to content
  • Advertisement
Sign in to follow this  
kruzoe

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

This topic is 4732 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

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 this post


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

Share this post


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

Share this post


Link to post
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.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!