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

Getting a curved healthbar

Discussion in 'Scripting' started by Fluzing, May 28, 2014.

  1. Fluzing

    Fluzing

    Joined:
    Apr 5, 2013
    Posts:
    815
    Hi All,

    I am trying to get a health bar as in the image below. I have found a few threads that suggest all sorts of stuff. Right now I have a circular mesh and I am using tiling to create a crude form of health bar. However, what I want is individual blocks to disappear instead of a sliding bar. I tried using a different texture, but I can't get it right. What would be the best method to achieve such a healthbar on IOS?

    Edit: ignore the laserbar. My other picture would not show up without it.

    $13330-laserbeamblue.jpg
     

    Attached Files:

    Last edited: May 28, 2014
  2. SiegfriedCroes

    SiegfriedCroes

    Joined:
    Oct 19, 2013
    Posts:
    569
    Please add the actual image ;)
     
  3. Fluzing

    Fluzing

    Joined:
    Apr 5, 2013
    Posts:
    815
    That is weird. It wont attach.
     
  4. Carpe-Denius

    Carpe-Denius

    Joined:
    May 17, 2013
    Posts:
    842
    You can use the alpha value of your texture in a shader. If alpha is above your health normalized (e.g. 0.5), show the texture color, if not, fully transparent.
    You have to set up your alpha channel with different alpha values for each of your blocks.
     
  5. Fluzing

    Fluzing

    Joined:
    Apr 5, 2013
    Posts:
    815
    That would require me to create a bended texture of the entire bar, wouldn't it?
     
  6. Fluzing

    Fluzing

    Joined:
    Apr 5, 2013
    Posts:
    815
    Ok, I made the grpahic with overlay, but which shader do I need? Transparent Cutout does not work properly.

    Edit: the image I made seems to be not good enough. Any tips?

    $statsbar.png
     
    Last edited: May 28, 2014
  7. Carpe-Denius

    Carpe-Denius

    Joined:
    May 17, 2013
    Posts:
    842
    Transparent cutout works for me, but you have to make your alpha channel independent from your colors. At the moment your slider is darker at the bottom.
     
  8. Fluzing

    Fluzing

    Joined:
    Apr 5, 2013
    Posts:
    815
    I am not sure what you mean.