Multiple waypoint solutions

This is kind of an ideas question more than an actual problem I ran into. Also I didn’t really know how to call the question.

I have multiple circular tracks on my map. Now I want to make trains move along those tracks. Preferably I don’t want to use waypoints, because I’d need ALOT of them to make the movement smooth since it’s a circular track and that would clutter my level alot with useless information.

So I’m asking how would you fix something like this? Object automatically moving around a static track without using waypoints?

Is your track describable with mathematical equation? If so, just use a mathematical equation for your position based on time.

Probably, not one I'd be able to pull off though. They're like large ovals with some inconsistent shapes in between.

Then what you can do is to define the shape with some way-points and make smooth transition between them using slerp( http://docs.unity3d.com/Documentation/ScriptReference/Quaternion.Slerp.html ) and moving forward your item. When you reach close enough then change to next way-point. OR research besier curves. I believe this tutorial would help: http://gameprog.it/articles/58/create-bezier-curves-with-unity#.UotcvuL1Us8 I didn't read trough so I can't be sure, but anyway what you want is to set up a bezier curve and move your train on it's path.

2 Answers

2

Have a look at a spline path. The spline interpolates between a few waypoints defining the track and it should generate a bezier curve depending on the waypoints orientation. You can use this interpolation to move and align your trains.

e.g. http://wiki.unity3d.com/index.php?title=Spline_Controller
or http://wiki.unity3d.com/index.php/Hermite_Spline_Controller

Use NavMesh Agent

This worked for me using Unity 5.2, thanks.