Game Development Reference
In-Depth Information
Since everything regarding player's health is handled trough PlayerHealth script, all we
have to do in this script is to receive the message OnPainfulHit along with provided damage
amount. This amount is then used as input value when calling DecreaseHealth() function
of PlayerHealth . If you run the game now with the player character inside the room, you
should be able to control the cube and try to avoid the projectiles that cannons shoot.
Illustration 85 shows a screen shot during game play.
Illustration 85: A screen shot of game play with player cube and projectiles
What we need to do now is to visually inform the player about his health status. Managing
the status internally is enough to know how much health the player still has and whether he
is dead or not. However, it is necessary to share this information with the player as well. One
option is to textually represent health amount, but there are unlimited other options. For this
example we are going to use color-coded health display. The color of the cube should vary
between red and green depending on the current health. When the health is full then the col-
Search WWH ::




Custom Search