void Update() { activeBehavior(); if (threats[0].inSight && threats[0].threatValue > 600) { agent.Stop(); activeBehavior = attack.Update; } //Debug.Log(activeBehavior.Method); }
void Start() { //Initialize behaviors inquire = new Inquire(this); patrol = new Patrol(this); attack = new Attack(this); StartCoroutine("threatUpdate"); canShoot = (gameObject.GetComponent <weaponController>()) ? true : false; agent = GetComponent <UnityEngine.AI.NavMeshAgent>(); if (patrol.enabled) { activeBehavior = patrol.Update; } else { activeBehavior = Idle; } }