Health system & blood effect
As we go on with the development of the enemy it becomes necessary to create a system to do/receive damage for both the player and the enemy.
I decided to use again the interfaces to get more confidence. As in the previous project, I am going to build an interface that has a method of Damage that must be implemented by the classes that implement this interface.
In the case of the zombie-enemy, when it will approach the player it will have to look for the interface of the player through the method OnTriggerEnter.
In the case of the player instead, we will use the raycast of our method that we use to shoot. In addition to the shot, we will add a small effect that will make the blood appear on the zombie at the point that will be hit by my bullet.
During the realization of the enemy, I created two colliders on the same object, one for the body of the enemy and one to define the area in which it should recognize and attack the player. This choice did not turn out to be one of the best because it led me to have a conflict when the effect of the blood did not arrive on the enemy but stopped on the first collider that met.
To solve this problem it was enough to create a new game object child with the collider in question. In this way, I could create a layer mask to pass in the call of my raycast simply assigning the mask to ignore raycast from Inspector.