Stamina Drain While Not Moving

I am using a basic stamina system using components. While key press the character sprints and stamina drains. BUT, it will also drain on key press while standing still (not moving).
Any ideas on a fix? Thanks in advance.

(I still want to be able to drain stamina while jumping in place)

This should be obvious but you need to add speed variable or check if moving before draining the stamina.

So Key press —> is character moving -----> if yes drain stamina/draw to bar

1 Like

Maybe you could work it out with a simple “is sprint key pressed” boolean, based on the input. And to make sure, work it out with your actual velocity compared to a speed that would justify the stamina drian. The branch then could be adjusting some logic within your stamina component whatever is doing it.