private var stopWaypointLoop: boolean;
function Start ()
{
functionState = 0;
stopWaypointLoo = false;
}
function Update ()
{
if(stopWaypointLoop == false)
{
if (functionState == 0)
{
Accell ();
}
if (functionState == 1)
{
Slow ();
}
waypoint = waypoints[WPindexPointer];
}
}
function OnTriggerEnter ()
{
functionState = 1;
WPindexPointer++;
if (WPindexPointer >= waypoints.Length)
{
stopWaypointLoop = true; // when the NPC reaches last waypoint, with this code we stop it from doing that.
WPindexPointer = 0; // NPC keeps going on waypoints.
}
}
↧