UE5 - Input Bindings not working in C++

Hello,

The attached code’s input bindings don’t work. I have added debugging logs, and discovered that while SetupPlayerInputComponent() is called, the Input Binding does not seem to work. You can see it in the code attached.

The thing is, this is the exact same code that I use for UE4 projects – which is part of what makes me wonder if this is an issue with UE5 deprecating it. But that doesn’t explain why it still works in Blueprints.

A potential solution would be for me to move to the new Enhanced Input System, but I am unfamiliar with it and if it works in Blueprint(and Unreal project settings does allow you to pick the legacy Input System, which is what I did), then it should work regardless.

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

    UE_LOG(LogTemp, Warning, TEXT("Set up input"));
    //set up gameplay key bindings
    check(PlayerInputComponent);

    //Movement
    PlayerInputComponent->BindAxis("MoveForward", this, &AStarshipCharacter::MoveForward);
    PlayerInputComponent->BindAxis("MoveRight", this, &AStarshipCharacter::MoveRight);
    PlayerInputComponent->BindAxis("MoveUp", this, &AStarshipCharacter::MoveUp);

    //Rotation
    PlayerInputComponent->BindAxis("TurnRight", this, &APawn::AddControllerYawInput);
    PlayerInputComponent->BindAxis("LookUp", this, &APawn::AddControllerPitchInput);
    PlayerInputComponent->BindAxis("Roll", this, &APawn::AddControllerRollInput);
}

void AStarshipCharacter::MoveForward(float Value)
{
    UE_LOG(LogTemp, Warning, TEXT("Moving forward"));
    if (Value != 0.0f)
    {
        // add movement in that direction
        AddMovementInput(GetActorForwardVector(), Value * PlayerSpeed);
    }
}