How do I combine L-Shift and W to sprint?

I don’t have Unreal open right now, but it should be possible to create an action mapping on pressing Shift. It should not be affected by whether you have W down or not.

So:

  1. Set up a new Action Mapping called “Sprint” on Left Shift under Project Settings > Input:

191889-map.jpg

  1. Add two functions to YourCharacter.h and YourCharacter.cpp to start and stop sprinting, and bind them in SetupPlayerInputComponent:

    // YourCharacter.h

    public:
    void SprintStart();
    void SprintStop();
    void SetupPlayerInputComponent(UInputComponent * PlayerInputComponent) override;

    // YourCharacter.cpp

    void AYourCharacter::SetupPlayerInputComponent(UInputComponent * PlayerInputComponent)
    {
    Super::SetupPlayerInputComponent(PlayerInputComponent);

     InputComponent->BindAction(TEXT("Sprint"), IE_Pressed, this, &AYourCharacter::SprintStart);
    
     InputComponent->BindAction(TEXT("Sprint"), IE_Released, this, &AYourCharacter::SprintStop);
    

    }

    void AYourCharacter::SprintStart()
    {
    GetCharacterMovement()->MaxWalkSpeed = 800.f;
    }

    void AYourCharacter::SprintStop()
    {
    GetCharacterMovement()->MaxWalkSpeed = 600.f;
    }

Here I’m just hardcoding the movement speed to 800 when sprinting and to 600 when not sprinting, but it should give you a starting point.

Thank you, it is much appreciated :slight_smile:

More specifically, how do I achieve running when I press L-Shift AFTER I have already started walking with W, like in call of duty?