Graphics Reference
In-Depth Information
// completed the route!
reachedLastWaypoint= true;
// if we are set to loop, reset the current
// WaypointNum 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;
}
}
With all of the manipulations to currentWaypointNum now complete, we can use it
as an index number to ask the waypoint controller myWayControl to provide the trans-
form for the next waypoint. currentWaypointTransform is set to the result of a call to the
Waypoint_Controller.cs function GetWaypoint():
// grab our transform reference from the waypoint
// controller
currentWaypointTransform= myWayControl.GetWaypoint
( currentWaypointNum );
}
}
Finally, in this epic BaseAIController.cs script, two small functions provide access to
the horizontal and vertical input variables:
public float GetHorizontal()
{
return horz;
}
public float GetVertical()
{
return vert;
}
}
9.3 Adding Weapon Control to the AI Controller
The BaseArmedEnemy.cs script is intended to be added to a player to take control of the
weapons system and deal with firing. It does not specifically reference or require the AI con-
troller, and it works independently, relying only on the Standard_SlotWeaponController.
cs script to operate the weapon and a separate class named AIAttackStates.
The AIAttackStates.cs script stores an enumerated list of the possible states for the
armed enemy to take:
Search WWH ::




Custom Search