// player takes damage (or gains health if damage is negative) public void TakeDamage(int damage) { if (!takingDamage) { health -= damage; healthBar.ChangeSliderValue(-damage); takingDamage = true; if (damage > 0) { hitSound.Play(); GetComponentInChildren <Animator>().SetTrigger("Hit"); } else if (damage < 0) { healSound.Play(); GetComponentInChildren <Animator>().SetTrigger("Heal"); } if (health > healthToEnrage) // Is in demon mode and regained enough health { switchState.enraged = true; switchState.Transform(false); } if (health <= healthToEnrage && health > 0) // Is in knight mode and lost enough health { switchState.enraged = false; switchState.Transform(true); } else if (health <= 0) // Died { //Destroy(gameObject); deathSound.Play(); GetComponentInChildren <Animator>().SetTrigger("Dead"); } } }