Game Development Reference
In-Depth Information
Let's now edit Kevin. Create a new group and call it Health . We are going to keep
all our health-related behaviors and rules inside this group to keep everything
organized. First off, we are going to spawn the two bars; so drag in two Spawn
Actor behaviors and select both the bars accordingly. You don't have to worry about
positioning because the bars are already constrained to the correct positions. Drag
in a Change Attribute behavior, and change it to Change Attribute: game.Health
to: 100 . This way, whenever a new level is started, he has fresh full health. All we
have to do when it comes to dying is create a new rule, change it to Attribute: game.
Health < 0 (which means when the player runs out of health, or if they reach below
0, which can happen, let's say you have 5 health remaining, and an enemy hits you
with 25 damage. We need to add that variable in as well), then drag in a Reset Scene
behavior. It is that simple. You could also do a dying animation, and when the
animation has completed, reset the scene.
We also have cracks and holes our hero can fall through. Instead of creating a new
actor at the bottom of the cracks and holes, we will just detect if he has gone below
the bottom of the screen and we will reset the scene.
Create a new Rule , change it to Attribute: self.Position.Y < 0 (when the player's
position has reached 0, or the edge of the screen, or lower), then drag in a Reset Scene
behavior; or you can have a Timer behavior and after a certain amount of time you can
reset the scene so it's not as abrupt, or so you have time to play a quick sound effect.
 
Search WWH ::




Custom Search