A Health (and Damage) system for everyone!
--
A shooter wouldn’t be complete without a health and damage system right?
This time for this project I decided to make a universal health script for both my test enemy and Player.
In this new script I made variables to be generic as it would be going on both the Player and the Enemy. Serializing the fields would also let me tweak them independently from each other.
Other than that, we have our typical damage and death system here. However the main meat of what is needed to be done due to the raycasting will be within our Shooting script that was made previously.
if the health script was gotten from whatever was hit, we do the damage amount of health.Damage(10). Hard coded but hey just to test for now.
An extra thing that was put in is with the Physics.Raycast, we have set up bitshift operators to determine what layers raycast will ignore or not. This prevents us from hitting ourselves!
With that we have a killable enemy, and well a killable Player as well!
See you next post!