public void TakeDamage(int damageAmount) { WhiteFlashManager.FlashWhite(gameObject); health -= damageAmount; if (health < 0) { health = 0; } }
void Awake() { if (Instance == null) { Instance = this; } else { Destroy(gameObject); } DontDestroyOnLoad(gameObject); }
// Checks if player is invulnerable. If not, reduces health by damageAmount. public void TakeDamage(int damageAmount) { if (Time.time - prevDamageTime > DamageInvulnDuration) // checking if invulnerability time is up { AudioManager.Instance.PlayPitch("Hurt", UnityEngine.Random.Range(1.5f, 2f)); CinemachineImpulseManager.Play("Strong Impulse"); WhiteFlashManager.FlashWhite(gameObject); prevDamageTime = Time.time; health -= damageAmount; } if (health < 0) { health = 0; } }