A prefab that shows a character's health.
-
Drag the prefab into the
Hierarchy. -
Make sure an
EventSystemexists in theHierarchy. (If not, you can create one by creating acanvaselement then delete it) -
Set health
public float maxHealth;
public float currentHealth;
public HealthBar healthBar;
private void Start() {
healthBar.SetMaxHealth(maxHealth);
healthBar.SetCurrentHealth(currentHealth);
}- Update current health when damaged or healed
currentHealth -= damage;
healthBar.SetCurrentHealth(currentHealth);// TODO: Add a tutorial video while there are plenty enough types of health bars

