Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Best UI method for Health Bar

Discussion in 'UGUI & TextMesh Pro' started by EilexInteractive, Dec 12, 2019.

  1. EilexInteractive

    EilexInteractive

    Joined:
    Dec 6, 2018
    Posts:
    5
    Hey Guys,

    I was just wondering what you think the best method to creating a UI Health bar. I've been using sliders but you're very limited to the design as I find the fill go's funny when you use odd shapes. I've people using an image with a mask and move the image with script.

    What do you use for you health bar? and what do you think is the best way to do it
     
  2. j4ke

    j4ke

    Joined:
    Dec 9, 2018
    Posts:
    21
    Simply by using UI image and using image.fillAmount to change and to display the health state:

    int maxHealth = 100;
    int currentHealth = maxHealth;

    health.fillAmount = currentHealth / maxHealth;