void Start() { // Start up the FSM aiStateMachine = new AIFSM("BaseController of " + gameObject.name, this); aiStateMachine.Start(EAIState.IDLE); // Cache a ref to our controlled character character = gameObject.GetComponent <BaseEnemyCharacter>(); character.gameObject.GetComponent <Health>().OnNoHealth.AddListener(OnCharacterDied); // Grab our nav mesh agent agent = gameObject.GetComponent <NavMeshAgent>(); // Bind to perception events eyes = GetComponentInChildren <Perception>(); eyes.OnSeenTarget.AddListener((newTarget) => { SeePlayer(newTarget); }); eyes.OnLostTarget.AddListener(LostPlayer); }