public void TakeDamage(int dam) { health -= dam; if (health > maxHealth) { health = maxHealth; } healthBar.value = health; if (health <= 0) { PlayerDied(); } if (dam > 0) { screenFlash.StartCoroutine("Flash"); screenShake.TriggerShake(); sound.PlaySound("hurt"); } healhText.text = "<b>Health </b>" + health + " / " + maxHealth; }
public static void Flash(float duration) { _instance.StartCoroutine(DoFlash(duration)); }