Entity Health Bars - UQdeco2800/2022-studio-3 GitHub Wiki

This page refers to the health bars displayed on the entities in game (this excludes friendly buildings). For Building health bars, refer to Building Health Bars

Health

The health and maxHealth displayed on the health bar are specified by the CombatStatsComponent of that entity. Each segment represents 25hp in the health (this can be changed). The health of the entity can be changed through the CombatStatsComponent and same with maxHealth. How these changes effect the health bar can be seen below The health bar is also scaled to the size of the entity so larger entities like buildings have larger displaying health bars

The Health bars displayed on the entities will hide after a period of inactivity (currently set to 15 seconds). Inactivity means no changes to health for a period of time.

Health bars can also be turned on to ignore inactivity using the debug on command

What it looks like in game

Friendly entity missing health Increasing max health of friendly entity
Enemy entity missing health Increasing max health of enemy entity
Building Entity Health Bar

Sequence showing the creation of a Health Bar

The HealthBarComponent extends from RenderComponent so it registers itself with the RenderService. The Health Bar gets the combat stats component to have access to the health of the entity. The Health Bar then gets the game time to know when to hide the health bar after a time of inactivity. It finally register an event listener to know when the health of the entity is updated.

HealthBarComponent_create