• Create Account

We're offering banner ads on our site from just \$5!

# [help] Moving along bezier curve based paths at consistent intervals

Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

1 reply to this topic

### #1bombshell93  Members   -  Reputation: 210

Like
0Likes
Like

Posted 26 March 2012 - 07:50 PM

I have a 3D path made out of bezier curves.
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,
Bombshell

### #2frob  Moderators   -  Reputation: 22263

Like
0Likes
Like

Posted 27 March 2012 - 08:17 AM

As you mentioned, computing distance through the curve will always be relative to the knot points. The formula for finding that spline point is simple, just a single matrix multiply. That's why games use splines so often.

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.

Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

PARTNERS