Damaging Enemies

Taking a slightly different route, I decided to add the ability to damage on the projectile rather than on the enemy/player. This way, if I create many different weapon projectiles with different damage values, I can adjust them and send those values over to the enemy object.

The key to this is to create a Damage() function on your object that needs to take damage. Every time this function is called, a chunk of health is taken away.

From the capsule perspective, it will check if whatever it collides with in the trigger has the enemy behavior and do a null check. If it does collide with the enemy and it has the enemy behavior, it will then tell the enemy to run the damage function.