Best way to give an enemy a heart/life system

indra.azizindra.aziz Member, PRO Posts: 100

Hey everyone, I'm currently making a defense game, where the player stops a forever spawning enemies from crossing a line behind the player by either shooting at it or hitting in close range.

Some of the enemy character types are harder to kill, the player has to hit them 2-3 times for it to get killed.

My question is, what is the best way to do this?

My first thought was to make a new integer attribute for the enemy actor, name it for instance self.heart and simply give it -1 each hit, and destroy it when it reach 0. But the problem now is this, since this is a continuosly spawning enemy, what can I do to reset the self.heart attribute back to the original value for each newly spawned enemy?

Would appreciate your thoughts on this. Thanks!

Comments

Sign In or Register to comment.