Issue with stamina drain and regen while jumping

Im absolutely in the weeds right now. Im currently setting up a stamina system where both sprinting and jumping drain stamina. The sprint system works perfectly fine. It drains stamina properly, theres a delay before stamina starts regenerating, and when I start sprinting again the regen is interrupted. Jumping is the problem child. As of right now when I jump it drains the proper amount of stamina, but then it doesnt regenerate stamina at all ever, and if stamina is regenerating from sprinting, jumping does not interrupt the regen at all.

The first image is the basic tree for what happens when I sprint, the second image is the tree for consuming stamina upon sprinting, the third image is the tree for regenrating stamina after it is consumed by a sprint The fourth image is the basic tree for what happens when I jump, the fifth image is the tree for consuming stamina upon jumping. The sixth image is the setup for stamina drain upon jumping, and the final image is the actual tree for stamina drain and regen after jumping

Your screenshots are too small - hardly readable.

What is the purpose of this bit:


The stamina will never ever be 0.55 (floats should be never checked with == in general)

This makes your next piece of code execute only when “Stamina Depleted == false”:

Why? This means that if you actually DO deplete your stamina, no regeneration will be ever triggered. This makes the following check

This makes it so after a jump the top path will never be executed:

So you are left in this recursive call with a timer. I can see you have a debug string there - does it show and when? (before/after jumping). Again, don’t check floats with ==.

I think your solution is a bit overengineered given the fact that you must implement so much code for each specific case. I would have gone with a simpler actor component that has 4 functions: StartDrainOverTime(), StopDrainOverTime(), DrainInstant(), GetStamina()

Not that I’ve written that, I don’t think you’ve made the things so much different but I would just encourage some more separation of responsibility here. I’ll leave it in anyway.