Progress Bar and Player Health only go between 1 and 0

I’m building a demo for a game I’m working on, however when working on the health bars for the UI, a few issues occur.

  • When the game starts, the health bar immediately fills. For reference, the max health is 100 and current health starts at 25.
  • When the health is updated using the updatehealth function, two things happen: if the player’s health is reduced, it goes to 0, if it goes up, it goes to 1.
  • The progress bar does nothing but care if the player has above 0 health or not, rather than being representation by a percentage.

Here’s my current setup:

Player UI Get_Health_percent

UpdateHealth Function:

This is what’s seen on the player’s screen.
Begin play: See that the currenthealth is being displayed as 25.0

Reduce health: it goes to zero, when the health is only reduced by 5.

Increase Health: the player’s health goes up by 5. goes to 1 instead.

Something has to setup improperly, or my health variable is being mucked with by the progress bar. Any ideas?

If curren helth was 50 and helth max was 100 = 50/100 = 0.5 you need afte multiply it x 100 to get percentuage so you need add a note x 100.
It must help if you screenshot your windget blueprint too.

The UMG health bar is in the 0-1 range. Since your health is between 0-100 you need to remap the value using the map range clamped/unclamped function.

That is of course hard coded. Your in range B should be your max health variable and Value should be your current health but you get the idea.

Simply divide your current HP by your max HP and you’ll get the percentage in 0-1 range.

Thank you, I think this is the answer I was looking for. Thanks for the help!