[help] Moving along bezier curve based paths at consistent intervals
Members - Reputation: 210
Posted 26 March 2012 - 07:50 PM
Naturally moving along the curve is in percentage increments. (0 none, 0.5 half way, 1 full length)
what is the simplest way to get an increment that would keep a consistent absolute speed going through 1 curve into another.
E.G. moving 5 units at a time, as opposed to 5% at a time which would vary with curve size.
Any and all help appreciated,
Thanks in advanced,
Moderators - Reputation: 22817
Posted 27 March 2012 - 08:17 AM
But computing the linear distance traveled requires solving an elliptic integral, which is a lot more processing. If you really need to compute accurately you will need good calculus engine; you generally cannot convert an elliptic integral to simple functions, nor can you generalize to an iterative solution.
For an game-useful iterative solution just continue to solve by percentage increments across the spline and have your object move toward that point at a constant velocity. When it would reach or cross that point move to the next increment along the spline. If your increment is small enough the curve will appear smooth, and if it is too small you can simply advance the point multiple times. If your spline contains something like a tight loop, your object will need to respond appropriately, probably by simply passing over the loop.
That way you can move at whatever linear speed you want while still iterating across the curve in percentage increments.
Check out my book, Game Development with Unity, aimed at beginners who want to build fun games fast.
Also check out my personal website at bryanwagstaff.com, where I write about assorted stuff.