Trying to make a COD style sprinting system

Hey all, brand new to UE5. Making a lil FPS game and I’m trying to make a sprinting system similar to COD and basically every FPS game ever. So far the system works like this: You can toggle between walking and sprinting by pressing ALT.

Problem here is, I need the movement speed to reset to the walking speed when my character stops moving. It’s currently setup to pick up the movement speed where it left off, and it only changes when I press my ALT key.

Saw a solution involving using a multigate instead of a flipflop, just not sure how to implement it. Any ideas?

Here’s my blueprint.

I haven’t tested this, but something along those lines could work as a quick fix

There is likely a more efficient way to know if we stop moving rather than checking each frame, so you could look into that if performance becomes an issue

Edit: The branch needs to use the “False” pin and not the “True” one, it’s an error on my side

No good, can no longer sprint but thank you for trying

Hello! You can try this

You’ll need to create two new custom events, named StartSprinting and StopSprinting, and a Boolean variable named bIsSprinting.

Using a FlipFlop node is fine for simple behaviour, but when you need to access to modify the internal state of the FlipFlop you are better off by moving that state into it’s own variable (in this case, bIsSprinting).

Also, having two separate events for starting and stopping sprinting will allow you to call them wherever else you may need them.

You can touch the “Tolerance” value and make it larger in case the character stopping isn’t detected, which may happen if the Character is drifting by a tiny amount when staying still because of physics. My guess you could set Tolerance up to let’s say, 5.0 or even more and it will feel just fine.

1 Like

Worked! Thank you so much