Game Development Reference
In-Depth Information
constant speed
const_dist = 2 //interpolate spline at
constant distance steps
};
4. A single variable of the type
ePlayback
encodes the type of interpolation
that the spline will use to generate points on the curve:
public ePlaybackType type =
ePlaybackType.const_dt;
5. A second enumeration encodes the playback mode that the
SplineMgr
class will use to generate points on the curve. The loop will continue the
playback in an infinite cycle. The
oneShot
mode will play the spline once
and then finish. The
ComputingDebugPath
and
ComputingDe-
bugPath_Finished
modes are used while evaluating the spline to gener-
ate points on the
lineRenderer
component:
public enum ePlaybackMode
{
invalid = -1, //error spline
interpolation
none = 0, //not spline interpolation
oneshot = 1, //play once and finish
loop = 2, //loop continuously
oneshot_finished = 4,//when oneshot is
done
computingDebugPath = 5, //internal
computingDebugPath_finished = 6
//internal
};
6. The
start()
method in the
SplineMgr
class performs two primary tasks:
• It allocates a new GameObject to move along the curve in front of the
HeadObj
object. This is to facilitate looking ahead of the curve when
the NPC is in the
patrol
mode and walking along the spline.