Stop using stamina when not moving

I have a system setup where when you hold shift down it activated a faster speed and simultaneously takes away stamina. This works while standing completely still however, and that is undesireable. I followed a tutorial “MVP FPS - Adding Stamina to our Sprint ( UE4 ) - YouTube” and didn’t use some of the variables such as “Is Sprinting”. I’m wondering if there is a way to only take away stamina if the character is actually moving. Please help, see code below.

add a check where you’re decreasing stamina, there’re a few ways to check if the player is moving. Check for the axis input values of the movement, like this:

so true means player is moving the pawn, false means it’s not.

Thank you, this worked perfectly. For people who may have this issue in the future, I’ll add a snip of my edited code.

The Get Vertical and Get Horizontal function nodes are my W, S, A, and D axis mappings, the name might be different than yours.

How do you get the staminia to drain again? Like I have it to where if you hold shift you drain stamina and when you stop while holding shift you regain stamina, only Problem is now when the stamina refilles, on character is stopped the stamia bar doesnt budge. Thus when moving the character again while still holding shift. The character now has infinite stamina which I dont want.

1 Like

I’m having this issue too. Holding shift first then moving causes using up stamina not to drain. I’m a complete noob but I’ll try my best to see if I can find a way to fix it and update if I find a way

Not too happy with it but I just moved the nodes to my InputAction sprint, with the branch going to the start sprinting function. The problem is that now you don’t sprint when holding down shift first.