How to build a very simple health bar in Unity

  1. Add a new UI > Image  to your project
    pick-ui-image
  2. Pick an existing sprite for the new imagepick-sprite
  3. Set Image Type = Filled and Fill Method Horizontal
    set-horizontal
  4. Moving the Fill Amount slider gives a preview on how the progress bar will work
    slider
  5. Now all we have to do is to set the Fill Amount value in code to whatever we like
    GetComponent<Image>().fillAmount = myHealthValue;

Done! 🙂

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s