Disable jump when energy is 0/ re enabling when above 0

Untitled.png is the BP that dosen’t work.

Working.png is the BP that does work.


float = float


float <= float

It looks like you’re triggering jump twice. The first one looks fine, but when you release the key for jump, it doesn’t check for anything, it just jumps a second time.

Try removing the “Jump” function from your release key, and perhaps also remove the “Disable input” node from the true part of your branch unless you mean to prevent the player from doing anything at all once he has no energy.

Besides that, I think everything is fine

Removed the jump function and disable input still not working/

What doesn’t work? Is Jump just not working at all, or is your energy value not going down?

i keep jumping even after my energy hits 0

Just occured to me. Try setting the energy value right after the jump function is executed instead of checking if the character is falling. It might be detecting that you’re falling because you’re in the air.

I’m not sure if you are regenerating energy yet but if you are that is most likely why it jumps infinitely. Either way you probably want to clamp the float you input in your current energy between 0 and your max stamina otherwise it can happen that you don’t exactly hit 0 while subtracting which means the equals check fails.On the other hand you could also replace your “energy equals no energy” with “energy is smaller or equal (<=) than no energy” which would solve this as well.

You also might want to not check against no energy but no energy - your jump cost. Otherwise you can jump with less energy than required. Not sure if that’d be intended.

And lastly the is falling check should probably be at the very beginning. Do you really want to be able to jump mid air for free?

Got it working! thanks a lot!

Thanks for the help! got it working!

Ah just real quick. I didn’t mean to change the variable name of “no energy” but actually the node behind that. You can name that whatever you want though honestly you probably don’t need a variable for this at all. It’s no energy. Unless you want to move this border around it will probably stay at 0.

What I mean is to replace the equal ("==") node with an smaller or equal ("<="). It’s already covered by the “clamp” node though a few things you should be aware of.

Also you can still drop below 0. You still have no check if you have more than 0 + “your jump cost” energy before you subtract it. With the clamp node like you have it will still get the correct result every time you have 0 or less energy but that’s not really what you should be going for. You should clamp when you subtract it to prevent this number to become negative.

Was just wondering if you ever found a solution to this?