I only ask this here cause I couldn’t find this information anywhere on the net. OK, so there are loads of tutorials out there on sprinting, and even the shooter game example has it. But as I go through all of those sprint mechanics, I realized that movement speed has increased to all directions. Now I only want to increase forward velocity instead of just max speed. How do I implement this in C++?

P.S. I know this is possible (Test it in Dirty Bomb)

First clarify with yourself if you even need to be able to sprint sideways/backwards. (usually you only sprint forward)

If that’s the case, you can just stop the sprint as soon as “forward” input is changed to something else.

if that’s not the case, it depends very much on your setup. please show how do you implement your movement here.


You need to check whether the character is moving in the same direction as its forward vector or keep track of which keys are held down and adjust the groundspeed accordingly. I use the latter approach with the following setup:

  1. Input Bindings for forward, backward, left, right start and stop keypresses

  2. Input Binding for Sprint start and stop

  3. Calculate which directional keys are held down based on 1)

  4. If sprint key is pressed, check that forward is the only directional key held down, otherwise cancel sprint

  5. Cancel sprint if any directional keys other than forward is held down on an ongoing basis

You effectively only increase the groundspeed when sprint is requested and the only directional input is forward.

bool DoesThatAnswerEvenHelpSomebody();