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!




Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

How to Reorder Data in Log Files having digit and letter logs?

tudaBirds introduces birdTris: Retro play #gamefi

Static libraries

Play with minikube

How to Use Remote Desktop Connection in Windows 10

Evrice: Applications and smart-contracts

About Smart WebLogic Server Monitoring and Diagnostic Tool WLSDM by Govindan Padmanaban

Revisiting Content Server browser performance

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Edward Kim

Edward Kim

More from Medium

Lerp Squares — Part 2

‘Dodge The Spike’-Endless Runner Tech Blog

2.5D Platformer: Moving Platforms

Unity camera plugin save image data as bytes