public void TakeDamage(int damage)
 {
     if (health > 0)
     {
         health -= damage;
         Mathf.Clamp(health, 0, maxHealth);
         if (health == 0)
         {
             OnDeath?.Invoke();
             UnTarget?.Invoke(this);
         }
         HealthChanged?.Invoke();
     }
 }
Exemple #2
0
 public void TakeDamage(int damage)
 {
     if (health > 0)
     {
         anim.SetTrigger(takeDamageHash);
         health -= damage;
         if (health <= 0)
         {
             health = 0;
             OnDeath?.Invoke();
             UnTarget?.Invoke(this);
         }
         HealthChanged?.Invoke();
     }
 }