Status Bar Problem

I followed the ue4 tutorial to do the hud of my game

So I noticed a problem, which I do not know if it is the tutorial or my mistake
I’ll try to post the video.

So how you can see my stamina has no limit
My jump action cost half of the stamina, if i jump 3 times instead of my stamina being set to 0, its set to -50
Banana recover half of the stamina, if I eat a banana when the stamina is already full it will add 50 more stamina, instead of being still with 100 I will get 150 stamina
It does not end at 0 or 100
What can I do to set limits?

Well is track a state. By bool. If I get what your saying.

Lets first say we want to see stamina change value but it’s not 0-100. Like your character might start that way but gather items raising the stamina to 300.

You’ll need a variable for current stamina and max stamina.

Then to update the bar you would divide current by max do it normalizes to a 0-1 ratio.

In the event of infinite you start the return instead of calculating to always return 1 because the branch you’d be using