public void UpdateHealth(float amount) { if (amount < 0 && lastHit + invicibleAfterHit > Time.time) { return; } health += amount; if (amount < 0) { lastHit = Time.time; audioSource.clip = ouchAudio; audioSource.Play(); if (cam != null) { cam.Shake(); } if (health < 0) { Game.Instance.GameOver(); } } if (InGameUI.Instance != null) { InGameUI.Instance.SetHealth(health); } healthScarf.SetLength(health); }
public void UpdateHealth(float amount) { health += amount; if (amount < 0) { hitTime = Time.time; audioSource.clip = ouchAudio; audioSource.Play(); if (health <= 0) { Die(); } } if (healthScarf != null) { healthScarf.SetLength(health); } }