Hi guys!
In my game I have 100 health and different enemies who deal different amounts of damage. The problem is that sometimes my health goes negative which I don't want to have. Probably the problem is that I have an enemy who deals like 50 damage and my current health is 60 so it goes negative. That is the way I tried to fix it (it doesn't do the job):
health -= damage;
currentHealth.text = health.ToString();
if(health < 0)
{
health = 0;
}
if (health == 0)
{
Die();
}
Die is basically setting the gameobject inactive. Any ideas?
I would be very grateful
Kind regards
↧