Modular health system in Unity

Dead Cells

Objective: How to implement a Health system that adapts to any case sceneario.

In most of games, we’ve seen that some characters react different when they take damage or when they die.

Let’s define a class that will adapt to any kind of project.

Declaring the fields

Here we defined the max health of our character and also the Damageable Team to identify if it’s an enemy or a player friendly entity.

The events are also a very imporntant aspect ot this piece of code. They will let us make a custom behaviour once the character is damaged or dies.

Writing TakeDamage() function

Everytime we want to make damage to an entity, we only need to call this function.

--

--