Stamina System Help

Ok so I’ve got a working stamina system with some basic HuD support now, just curious about an issue I’m having with it atm. I’ve got actions like Jump set to drain a set amount of Stamina each time you press the input and if you don’t have enough to jump then you can’t jump. Simple enough, but the issue appears that I lose Stamina every time I press spacebar to jump even when my character is in the air (aka there can be no jumping there so it shouldn’t be draining it). So is there a way to check if the character is in the air/falling to stop it from doing this?

Btw Here is the layout I currently have for it:

Not got UE4 with me at the moment, but you could have a boolean variable ‘InAir’. When they press space, it checks if the value is false. If it’s false, set it to true and carry on. If it’s true (they’re in the air), do nothing.

Then look for something along the lines of an OnLanded event for the character. When that event is triggered, set the InAir boolean to false.

Yup that worked! Thanks for the quick reply :slight_smile:

edit
Here’s a pic of what I did for future readers of this:

Just checked the blueprint, you might want to put the “Set In Air to true” after the jump at the end, otherwise it might set it to true when they have no stamina, and since they don’t jump they won’t land and it’ll stay “true”, so they won’t be able to jump again.

Ah didn’t notice that, will make the change now then. Thanks for that :slight_smile:

This better? I wasn’t able to break it like you mentioned before so I think I got it now:

Do you think you could put up some pictures of how you got your variables to send to the HUD? it’s something I’m having a lot of trouble with at the moment, interfaces are confusing the **** out of me :\ also, how did you do the stamina bar? increasing and decreasing in size as the variable changes?

The most clean approach would be to get your characters MovementComponent and check if the MovementMode Is un-equal to Flying before executing the jump.

Wasn’t aware of that, I’ll try it out and see how it goes :slight_smile:

@Leonn3k
"Do you think you could put up some pictures of how you got your variables to send to the HUD? it’s something I’m having a lot of trouble with at the moment, interfaces are confusing the **** out of me :\ also, how did you do the stamina bar? increasing and decreasing in size as the variable changes? "

Yeah I know how frustrating things can be when you just can’t wrap your head around something, but luckily as with most things UE4, it’s not that hard. I’ll take some node screenshots for you later today to try and help you figure it out.

You could also use the IsFalling node:

It’s what I used in my Stamina/Charged Jump setup and has been working so far.

-W

So many nodes I wasn’t aware of, thanks for this you guys :cool:

Hey I made a new thread with a quick tutorial on what I did here:

Figured I’d let you know in case you were just watching this thread. Hope it helps ya :slight_smile:

I have been actually haha :smiley: Thanks a bunch!