I have a blueprint in the ThirdPersonCharacter to do sprinting. Sprinting is activated by holding Left Shift and will consume stamina as long as it’s held, then once released stamina will regen. If you run out of stamina you stop sprinting and regen won’t start until the key if released. This is working great. However, if you hold the key while the character isn’t moving and then begins moving, no stamina is consumed. For the life of me I cannot figure out how to perform the stamina decrease event is the key is pressed before movement. Please can someone help?
Ps sorry for the disjointed image; the blue print was too big to get all in one screenshot
Ah ok. Maybe try moving the vector check to the decrease stamina event, right before that first current stamina check branch. That way when shift is pressed, it is running the decrease stamina event but shouldn’t go through if the character is not moving.
In your Decrease Stamina custom event call, currently you first check if the Current Stamina is less than or equal to 0. Do the vector check right before that check in the actual Decrease Stamina event.
Also, instead of doing it on tick, like Sarrin23 was suggesting, you could make a timer by function(that starts on event begin play) and have it check at a smaller interval rate like five times per second. If you were frame capping at 60fps, changing that function to only update five times per second would result in a 92% decrease in it’s load and it would barely even be noticeable to a player.
Obviously, there are far more efficient ways to go about the check though and event driven would be the way to go.