Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I made a little critter that roams around.

var boundary = 10.0;
var startingPoint = <0.0,0.0>
var destination = startingPoint+<randMinMax(boundary-(boundary*2),boundary),randMinMax(boundary-(boundary*2),boundary)>;

It generates a random destination (x,y) within a 10 meter area around its starting point. It then moves to that point, stops, then generates a new point, turns around and faces to the new point, and continues toward it. When it reaches its destination it does the same thing over and over.

This is sufficient for just wandering around using x,y but for flight I want to implement the use of the z axis. So I modified a copy of the script to do the same thing to the z axis, with tweaks and hacks it looked alright flying around, but it appears too programmatic.

I want to take flight to the next level, now I'm not great at math, and a google search shows that 3X^2 + 4X + 6 = 0 can help me calculate a curve, I am looking for advise on how I can apply this to curve the travel when the critter reaches its destination so as to create a 'swooping' movement effect as it moves around (curved x,y,z) to its new destination. This all is begining to seem quite complicated, and I realize that the flight path cant be so random.

Has anyone got any advise for generating 3d flight paths , or assistance applying curve to x,y,z ?



share|improve this question
add comment

1 Answer

up vote 3 down vote accepted

For smoother-looking motion, try looking into splines, specifically Catmull-Rom splines (that link is a nice intro, and you can Google 'em; there's plenty more information on the web).

You can use the last two points and the next two points as Catmull-Rom control points and animate the creature along the spline, and the motion should be smooth. Of course this means you'll have to keep track of the last two destinations, and generate destinations two points in advance rather than one. It's just a little extra data to keep track of.

share|improve this answer
I am very impressed by your answer. I managed to reverse engineer the XNA DirectX implementation and port it to my desired environment. This is a brilliant algorithm for smoothing, even if I was hoping for something a bit more powerful in terms of curve width, but I can work with this. Thank you –  Chris Oct 23 '11 at 13:27
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.