I have two scripts Enemy and EnemySpawner. In enemy I have a variable “health”. When health <= 0, enemy die and play die animation. But some of enemies are immortal after spawn. Maybe somebody know how fix this bug.
GitHub link : https://github.com/skrudgemacdac/-/tree/main
Most of your “am I dead” checks in the enemy script are checking if (health != 0)
But what if health is negative? There’s nothing in your TakeDamage function to prevent negative numbers - as you just do health -= damage;
So either clamp your health to only go to zero and not lower, or change your checks to account for negative numbers.
Thanks bro. Problem solved. I just changed all “health == 0” on “health <= 0”