Hello, i'm a beginner and i need some way to make a cooldown for stamina regen, i need it to regenerate a certain amount at a time but i can't figure out how to do it in an efficient way whenever the stamina goes below a certain amount, i tried using a Timer but i'm really struggling with it, any help would be appreciated.
for cooldowns i usually use delta timers and main _process function, here i update every object and node in my game that exists, for instance let’s say you have player object
we create stamina with setter so we could clamp (limit value between two other numbers) any new value we give to it
in update function we check if we’re sprinting (i assume you want to remove stamina while sprinting) and then subtract stamina multiplied by delta to avoid frame rate bugs
if we aren’t sprinting we add stamina multiplied by delta again
i got it working so thanks alot, only issue now is that now the stamina becomes a float when it regens, i need it to be an int value cause this is for a dash system that consumes and then regenerates stamina
Why do you need it to be an int? Almost every single game I know, Stamina bars are a float since it’s easier to deal with and have a smoother curve you can represent on a progress bar. Having it be an int would require a lot of back and forth conversions.
Could you tell us why you need it to be an int exactly?
at the moment i’m trying to make a dash with a cool down and limited dashes so i was thinking to have an int based system cause its only big bursts of stamina that needs to be removed and regenerated, i also realize that in that case i may as well just use a normal cooldown rather than a stamina based system
DANG i’m so sorry for wasting all of your guys time, i just realized thats exactly how dashing works in most games anyway, i can’t believe it took me so long to realize, thanks for taking your time to try and help though