# How to make movement speed dynamic?

I have a Walk Speed

When Sprinting:
Forward Speed: 2x Walk Speed
Left/Right/Backwards: 1.5x Walk Speed

When I press sprint button and move forward, the character sprints in 2x Walk Speed. When I let go of forward direction and press left direction while still holding down shift, it sprints in 2x Walk Speed insead of 1.5x Walk Speed. I guess whatever direction I press first overides the speed of other directions when holding shift. How do I fix that?

You should probably apply the walk speed modified on Tick rather that when pressing the Run button.

When pressing/releasing Run, simply set a boolean variable to true/false.

On Tick, get the current user input vector, normalize it as a 2D vector (just in case), then use Dot to compare user input to character direction. Depending on what you want to happen when user runs diagonally and how you want to support analog input, you can then either :

• Define Dot thresholds for the various speed multipliers you want to apply

• Interpolate / smoothly adjust speed according to direction. Dot is equal to 1 when direction vectors are equal, 0 when perpendicular, and -1 when opposite. So if you take the result of `1 + (Dot+1)/2`, you should get the desired movespeed multiplier curve.

You can get user input vector via `GetPendingMovementInputVector` or `GetLastMovementInputVector`. Try the former first, and the latter if it doesn’t work.