float timer; // Timer for counting up to the next attack. void Awake() { // Setting up the references. player = GameObject.FindGameObjectWithTag("Player"); playerHealth = player.GetComponent <PlayerHealths>(); enemyHealth = GetComponent <EnemyHealth>(); anim = GetComponent <Animator>(); }
void OnCollisionEnter(Collision col) { //S'il rentre en contact avec un objet if (col.gameObject.tag == "Building" || col.gameObject.tag == "Soldier" || col.gameObject.tag == "TownHall") { //Donne les référence de la cible target = col.gameObject; targetHealth = target.GetComponent <PlayerHealths>(); targetInRange = true; } else { target = null; targetHealth = null; targetInRange = false; } }