Developing the Health System

During this month I started a tutorial to learn how to build a RPG game. The reason i have decided this path is to grasps the basics and better a fundamental structured core game mechanics before tackling the creative part. One of the first things I did is adding a health bar system to the game. In this particular RPG a health system is important as the objective would be about avoiding the enemy as well as dealing damage to the enemy.

To do this I first create two scripts for the player and enemy. Below is example of the what the script looks like.

Figure 1: Player and Enemy Script

Inside the scripts i then created the Max health and Current health public integers variables to store the players and enemies health. As well as creating a box to show the bars i also created an If Statement condition that allows the hp bar to deplete based on the collision between the player and the enemy. Below is the end result of the health bars.

Figure 2: Health bars

Leave a Reply

Your email address will not be published.