SOLVED Able to Perform Action with Stamina at 0


Hello, I've run into a problem. I've been looking at different stamina tutorials and fuel systems, but I'm having an issue where I'm still able to perform an action even when my stamina reaches 0.

Player Object - Create has this:
global.stamina = 100;
Player Object - Step has this:
if (keyAttack && global.stamina > 0)
    state = PlayerStateAttack;
    stateAttack = Attack1hSword;
    global.stamina -= 25;

global.stamina += 1;
global.stamina = clamp(global.stamina, 0, 100);
I have the stamina bar drawn to the screen, I can see 25% of the bar move down each time I attack and also see the bar fill back up to 100 when not attacking. However, even when the bar gets down to 0, I'm still able to attack. I'd like it to where the stamina needs to reach 25 or more before another attack is possible.

Any help would be appreciated!


Well, that's easy enough. Instead of telling it to attack when stamina is higher than 0, change it to 25.
  • Like
Reactions: ERK