I’m trying to add health bars to my enemies and I have some code written to do so, it isn’t working, I just need help to figure out how to get this working
here’s the code
using UnityEngine;
using UnityEngine.UI;
public class Target : MonoBehaviour{
public float health = 50f;
public Slider slider;
void Start()
{
slider.value = health;
}
void update()
{
slider.value = health;
}
public void TakeDamage (float ammount)
{
health -= ammount;
if(health <= 0f)
{
Die();
}
void Die()
{
Destroy(gameObject);
}
}
}
any help will be greatly appreciated and if you need any other code just tell me.