Reduce Walkspeed while Aiming & Sprinting

I wanted to try modifying the players walk speed. It was actually quite simple. I have a sprint mechanic and a reduce speed while aiming mechanic. Here are my blueprints for the FPSCharacter

First I created a variable to store my initial walk speed. This is set on BeginPlay. You will need to drag in the Character Movement Component and from that call GetMaxWalkSpeed, then set the initial walk speed variable
Capture

Next, i set up my aiming walk speed. I multiply the initial walkspeed by another variable I called AimSpeedMultiplier. I have this set to 0.5. When Aim is pressed this will reduce the walk speed, and when released I reset to the initial walk speed. This is done by calling the SetMaxWalkSpeed function from the Character Movement Component.

Finally, To set up sprinting I created a new input action called Sprint and bound the necessary keyboard and controller keys.

Similar to how I set up the walk speed for aiming, I use a variable I called RunSpeedMultiplier which I set to 3.0. I multiply by my initial walk speed and again set the max walk speed by calling the SetMaxWalkSpeed function on the Character Movement Component. When pressed, the player will sprint, when released the walk speed is reset to its initial value. I have also set up a branch to prevent the player from sprinting while IsAiming is true.

Have fun

Privacy & Terms