Graphics Reference
In-Depth Information
if(AIController==null)
AIController= myGO.AddComponent<BaseAIController>();
// run the Init function from our base class
// (BaseAIController.cs)
AIController.Init();
// tell AI controller that we want it to control this object
AIController.SetAIControl(true);
// tell our AI to follow waypoints
AIController.SetAIState( AIStates.AIState.translate_along_waypoint_path );
// set a flag to tell us that init has happened
didInit= true;
}
public virtual void SetWayController( Waypoints_Controller
aWaypointControl )
{
if(AIController==null)
Init ();
// pass this on to our waypoint controller, so that it can
// follow the waypoints
AIController.SetWayController(aWaypointControl);
}
}
14.3.5.1 Script Breakdown
The BaseWaypointFollower class derives from ExtendedCustomMonoBehavior, which
adds some extra functionality and common variables:
public class BaseWaypointFollower : ExtendedCustomMonoBehavior
{
As per most of the scripts in this topic, Start() calls Init():
public virtual void Start ()
{
if(!didInit)
Init();
}
Init() creates references to the transform and gameObjects, and the variable
AIController is set (GameObject.GetComponent() looks for BaseAIController):
public virtual void Init ()
{
// cache our transform
myTransform= transform;
// cache our gameObject
myGO= gameObject;
// cache a reference to the AI controller
AIController= myGO.GetComponent<BaseAIController>();
Search WWH ::




Custom Search