Health System
Overview
The Health System provides a unified solution for handling damage, health state, and health visualization for both player and enemies. It consists of a set of interfaces, core health logic, and UI components responsible for displaying health changes.
Health class
When working with the health system, pay attention to the Health class.
Health is a base class that tracks an entity’s health, provides its current status, and notifies other systems when health changes or the entity dies. It can be reset or initialized as needed and supports integration with damage and gameplay systems.
This class is fully implemented and thoroughly tested. It is not intended to be modified directly; any changes should be made by extending it through a derived class.
Built-in Health Implementations
The project provides three built-in classes that inherit from Health to manage the health of different entity types:
PlayerHealth– manages the player’s health using data from the player context.TentacleHealth– manages a tentacle’s health using data from the tentacle context.EnemyHealth– manages an enemy’s health using data from the enemy context and interacts with the enemy state machine to trigger hit reactions when damaged.
Health Visualization
To visually represent an entity’s health using a UI bar, the abstract HealthBar class is used.
HealthBar serves as a base UI component that connects to a health model, responds to health changes and death events, updates the visual state of the health bar, and provides a position for displaying damage text. This class is intended to be inherited from and is not used directly.
Built-in HealthBar Implementations
The project includes ready-to-use HealthBar implementations for different types of entities:
PlayerHealthBar — a health bar implementation for the player. In addition to health visualization, it manages ammo count display, low-ammo visual warnings, and player UI visibility.
EnemyHealthBar — a health bar implementation for enemies. It automatically becomes visible when the enemy takes damage and hides itself when the entity dies.
Prefabs that display unit health can be found here:

To learn how to add a health system to a new unit, see here: [link]
Last updated