How do I make my health bar slider value increase every second?

Hi there,

I have a hunger bar set up with a slider component. I set the max value for the slider to 100, and the minimum value to 0. I want the slider to start at 30 and increase by any given amount every second; how would I code this?

Thank you for your time :slight_smile:

@shanecihelka, set up a co-routine to add your given value with a yield waitForSeconds inside a loop that runs as long as current health < 100:

so in pseudo code:

// set your health and health bar to 30 prior to starting the coroutine
//  set given value prior to starting the coroutine
// inside your co routine
current health = health
while current health < 100 {
      current health = current health + given value
      if current health >= 100, then current health = 100
      set health and healthbar = current health
      yield return new WaitForSeconds(1);
}