How to control speed of object move along a bezier curve path.
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.
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 :)
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 :)
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement