So I made a code when I hit the boss 10 times it dies but I want to add a health bar to the code so when I hit the boss the health goes down. I made a simple slider for the health I just want to know how to add the health bar feature.
using System.Collections.Generic;
using UnityEngine;
public class BossHealth : MonoBehaviour
{
[SerializeField] float health, maxHealth = 10f;
private void Start()
{
health = maxHealth;
}
public void TakeDamage(float damageAmount)
{
health -= damageAmount;
if(health <= 0)
{
Destroy(gameObject);
}
}
}