Sign in to follow this  
kruzoe

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

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this