I see your score text and raise you a health bar!

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.

5 Likes

Fantastic job with challenging yourself! Congrats on making yourself a health bar.

1 Like

Great job! The information about using a UI slider was exactly what I needed as I couldn’t figure the best way to implement a health bar myself.

1 Like

Wow! Your game is fantastic!

1 Like

@Kocian Thanks so much! I really had fun with this one although I would do things a bit different if I made it again.

Brilliant! Gosh that bird is zippy.

1 Like

Great! Congrats :clap:t5:

1 Like

Privacy & Terms