- Home /
Question by
Reubenater · Apr 26, 2015 at 11:40 PM ·
script.
How do I add health to an enemy
i currently have bullets that enemies and they both get destroyed. but I have a bigger enemy and I want it to have more hit points.
Comment
Answer by DoTA_KAMIKADzE · Apr 26, 2015 at 11:42 PM
I have no idea what your code looks like but you need to do something like this:
1) Add health variable:
//let it be int for our example:
private int bossHealth = 10;//so let's imagine that 1 hit = 1 health -> he will take 10 hits and only then die
2) In your code where your enemy should die and be destroyed or whatever - make a condition that should look something like that:
//if hit with bullet:
if (bossHealth > 1) bossHealth--;
else //your die code
That's it.