Really having fun with challenging myself. Since I added my own health system previously I decided to implement a health bar alongside the score text.
Here you can watch my video:
I used a slider to implement the health bar similarly to the way it is done for the level timer in Glitch Garden from the 2D course (I highly recommend this course)
My health bar script looks like this:
using UnityEngine;
using UnityEngine.UI;
public class HealthBar : MonoBehaviour
{
public Slider slider;
public void SetMaxHealth(int health)
{
slider.maxValue = health;
slider.value = health;
}
public void SetCurrentHealth(int health)
{
slider.value = health;
}
}
There is more that went into implementing it but as it was mostly catered to my specific uses I didn’t include it here but if anyone has a question about how I did something I can take some screenshots.