Game Development Reference
In-Depth Information
Enemy health
As you've probably guessed, it's super easy to give the enemies health. You're right!
We are going to follow the same procedure of giving Kevin health. Go into one of
our enemy actors, and you guessed it, we are creating a new Integer attribute. Name
it Health , and assign its value to 5 (or larger for tougher guys).
Now all we have to do is create a new rule, change it to Actor receives event |
overlaps or collides | with | actor of type | GravRound (to avoid having to create
this rule, numerous times you can create a new tag for all the projectiles and just
detect collisions with actors of the tag), then drag in a Change Attribute behavior, set
it to Change Attribute: | self.Health | to | self.Health -1 .
Now we need to create another rule to detect if the health reaches zero. The new rule
will be Attribute | self.Health | < | 0 (when the health reaches zero, or goes past
zero), drag in an Animate behavior and select the dying animations. We want to stop
him from moving as well, so drag in a Constrain Attribute behavior, change it to
self.Motion.Max Speed | to | 0 , then add in a Timer behavior, change it to After
0.5 seconds . Finally, drag in a Destroy behavior.
 
Search WWH ::




Custom Search