// Update is called once per frame public void TakeDamage(int damage, GameObject caller) { HealthBar healthBar = transform.Find("Healthbar").GetComponent <HealthBar>(); EnemyAgent agent = this.transform.GetComponent <EnemyAgent>(); Animator animator = this.transform.GetComponent <Animator>(); agent.AddAttackAggro(caller); currentLife -= damage; float percentLife = (float)currentLife / (float)maxLife; healthBar.SetSize(percentLife); if (currentLife <= 0) { StartCoroutine("DestroyEnemy"); } else { StartCoroutine("Stun"); } }