void Awake() { player = GameObject.FindGameObjectWithTag("Player").transform; playerHealth = player.GetComponent <GlobalHealth> (); enemyHealth = GetComponent <EnemyHealth> (); nav = GetComponent <UnityEngine.AI.NavMeshAgent> (); }
float timer; // make sure things are happening in sync (enemies arent attack too fast or too slow void Awake() { player = GameObject.FindGameObjectWithTag("Player"); // gets the player and stores the object locally in the Awake function for use later so references arent always neded. playerHealth = player.GetComponent <GlobalHealth> (); enemyHealth = GetComponent <EnemyHealth>(); }