Graphics Reference
In-Depth Information
// drop out of this function before
// we grab another waypoint into
// currentWaypointTransform, as
// we don't need one and the index
// may be invalid
return;
}
} else {
currentWaypointNum++;
// now check to see if we have been all the
// way around
if( currentWaypointNum>=totalWaypoints ){
// completed the route!
reachedLastWaypoint= true;
// if we are set to loop, reset the
// currentWaypointNum to 0
if(loopPath)
{
currentWaypointNum= 0;
// the route keeps going in a
// loop, so we don't want
// reachedLastWaypoint to ever
// become true
reachedLastWaypoint= false;
}
// drop out of this function before
// we grab another waypoint into
// currentWaypointTransform, as
// we don't need one and the index
// may be invalid
return;
}
}
// grab our transform reference from the waypoint
// controller
currentWaypointTransform= myWayControl.GetWaypoint
( currentWaypointNum );
}
}
public float GetHorizontal()
{
return horz;
}
public float GetVertical()
{
return vert;
}
}
9.2.1 Script Breakdown
The AI script begins with the usual namespaces (default ones added by Unity to all
C# scripts) as well as AIStates seen earlier in this chapter. By including AIStates as a
namespace, it may be accessed as though it were part of the same script:
Search WWH ::




Custom Search