Graphics Reference
In-Depth Information
// check to see if we hit the target
if( hit.transform.gameObject == aTarget.gameObject )
{
return true;
}
}
// nothing found, so return false
return false;
}
The AI controller incorporates waypoints control into the mix using the Waypoints_
Controller.cs script to manage them. Since the AI bot does not know which waypoints to
use, another script (such as the game controller) will call SetWayController and pass in a
Waypoints_Controller object:
public void SetWayController( Waypoints_Controller aControl )
{
myWayControl=aControl;
aControl=null;
totalWaypoints contains a cached value of the total number of waypoints from the
waypoints controller to save having to look it up every time it is needed by this script:
// grab total waypoints
totalWaypoints = myWayControl.GetTotal();
If shouldReversePathFollowing is true, the starting waypoint will be the last one
found in the list of waypoints made by the Waypoints_Controller script:
if( shouldReversePathFollowing )
{
currentWaypointNum= totalWaypoints-1;
} else {
currentWaypointNum= 0;
}
Among other things, the Init() function in this class caches a reference to the AI bot's
transform in the variable myTransform. The SetWayController() function calls Init() to
make sure that the reference is set up and ready for it to use, as it repositions myTransform
at the first waypoint (when the Boolean variable startAtFirstWaypoint is set to true):
Init();
// get the first waypoint from the waypoint controller
currentWaypointTransform= myWayControl.GetWaypoint( current
WaypointNum );
if( startAtFirstWaypoint )
{
// position at the currentWaypointTransform position
myTransform.position= currentWaypointTransform.
position;
}
}
Search WWH ::




Custom Search