Stamina Bar that goes down after 20 seconds

I can’t wrap my head around how to make a stamina bar that goes down as you run. I have a simple continuous resource bar set up but I have zero idea how to make it work.

Simply put, the stamina bar should count down to 0 from 20 (not visible) while Lshift is held down, then when it reaches 0 it should force you to walk, with an animation that shows the bar emptying

instead, currently it does not animate the bar emptying, and only allows you to run for less than a second.

This is code from a previous persons question, I have no idea how it’s supposed to work or if I’m missing some variables or behaviors that weren’t pictured, but it’s something to build off of

Hi @zizabel

The events have multiple issues and I think the method is a bit flawed (or it works in a different way than how you want it). I suggest you change the way it works. I created my own version (screenshot).

How it works: The player can sprint as long as the stamina is above 0. When the stamina reaches 0, it starts regenerating and forces the player to walk until it reaches 100, then the player can sprint again… In my example, the stamina depletes & regenerates by 0.5 each frame, if you feel it’s fast then you can change the numbers to something lower.

1 Like

That worked, but I don’t know how to get the resource bar to show how much stamina is currently available

What are you using as a resource bar?

the object Resource Bar (continuous) selected from the object list, with my own fillbar, buffer, and background

Set the value of the resource bar, like:

image

1 Like

this didn’t work, the stamina bar still isn’t showing how much stamina is left

nevermind, I wrote the name of the variable wrong, thank you.