How do I add a check before executing a command?

Very simple.

I have a character with stamina variable, it decreseas/increases on various factors.

I have button that when pressed makes my character sprint. Character loses stamina while sprinting.

This all works well.

The problem is that I have a condition to allow the character sprint which is Stamina > 5.

Now, this works very well if i press the button when the character has 5 or less stamina it doesn’t sprint.

But if the character is already sprinting and his stamina drops at 5 or below he will keep sprinting forever and won’t stop.

How do I make him stop?

A quick way to do this would be to put a check on your Tick event. If stamina goes below 5 then you have a branch that stops the sprint. Not sure if that’s the best way, but should work in a pinch I think.

How do I stop the sprint?

The easiest way would be to revert velocity to standard one but this should also check if character is in air, is crouched, ecc, ecc doesn’t seem very pratical to me.

This is the run/sprint part of the BP:

This is the event tick that checks in which movement state I am (tied to an enum) and changes stamina accordingly:

Okay, I fixed it by creating an event thick that connects to a branch condition, if the condition (stamina >5) is not met it sets maxwalkspeed to normal value instead of sprint.

Works very well.