Health System
Hello there!
Last time I created the system for attacks for both players and the enemies. Now it is time to add a health system so that these attacks actually inflict damage when landed upon either a player or an enemy. To do this, I split the system into three separate scripts to allow for an easier time in creating the health/ damage system.
The first script is assigned to the player and works as their health system. The script assigns the player a maximum health stat (100 in this case) and a current health to keep track of when the player has taken damage. The script keeps track of the players' health until it is reduced to 0 in which the level will reset and the player must start it again.
The enemies' health script works almost identically to the players', there is a maximum health stat (also 100) and a current health variable which will track how much the enemy still has after being attacked. The difference comes in when the enemies' health reaches 0, in this instance, the "Die" function will be called and will destroy the game object as the enemy dies and is removed from the scene.
Finally, there is the damage dealing script. This is a simple script which determines how much damage the projectile will deal (25 in this case) and will apply it upon collision with either the player or the enemy and deal with the damage function accordingly.
And that's all for now, thank you very much for following along and be sure to stay tuned for more updates. See you next time!
Get Freedom
Freedom
Status | Released |
Author | Starbound Interactive |
Genre | Shooter, Platformer |
Tags | Arcade, Robots, Singleplayer |
More posts
- Reaching The EndJun 20, 2023
- Enemy Health SystemJun 20, 2023
- Attacking FunctionalityJun 13, 2023
- Creating an EnvironmentJun 13, 2023
- Unity DevelopmentJun 07, 2023
- Welcome BackJun 07, 2023
- Early DaysApr 18, 2023
Leave a comment
Log in with itch.io to leave a comment.