- Home /
Recommendations for a script/plugin for creating set, curved paths
Hello all,
I would like to create paths for my enemies and would like the paths to be as smooth as possible. No AI is involved at the moment - I would just like to be able create various curved paths for them to follow. I've tried a few waypoint scripts but they require a large number of empties for anything that looks smooth.
Therefore, I am looking into alternatives. There are a number of spline/bezier path creating plugins on the Asset so I wanted to get a few recommendations if possible. Also, if there are any scripts that you know of that can make this task easier then please let me know. Unfortunately, iTween is out as it's paths cannot be parented to an object/prefab.
Thanks.
Answer by ScroodgeM · Aug 08, 2012 at 09:50 PM
this answers can looks crap and unuseful, but works very fine in one of my projects 8)
if you have set of values and need smooth moving between them even at both sides of value (so where before smoothly goes to after), you can use programmaticaly creating animationCurve. setting keys to it will make a smooth graph of moving via these keys.
look below - input data is set of numbers 3,10,15,0,20,12,5
output data is smoothed line that intersects all these points. (see pic). this created programmaticaly at runtime.
can be used as well for vectors (separately for coordinate components) and results in smooth path using only main checkpoints.
Smoother.cs
using UnityEngine; using System.Collections; public class Smoother : MonoBehaviour { public int[] CheckPoints; public AnimationCurve c; void Start() { Keyframe[] kf = new Keyframe[CheckPoints.Length]; for (int i = 0; i < CheckPoints.Length; i++) { kf[i] = new Keyframe(i, CheckPoints[i]); } c = new AnimationCurve(kf); for (int i = 0; i < CheckPoints.Length; i++) { c.SmoothTangents(i, 0.5f); } } }
That sounds good! Very nice idea to use AnimationCurve for movement by code.
Answer by wondersonic · Aug 21, 2012 at 03:05 PM
Eventually, try iTween (google it) plugin with a path editor.