In the function MoveForward in the character, the pitch is filtered from the rotation, but then the original unfiltered rotation is used, causing movement to change speed if you’re not looking exactly straight ahead with the camera.
MoveRight is implemented correctly.
void AThirdPersonCodeExpCharacter::MoveForward(float Value)
{
if ((Controller != NULL) && (Value != 0.0f))
{
// find out which way is forward
const FRotator Rotation = Controller->GetControlRotation();
const FRotator YawRotation(0, Rotation.Yaw, 0);
// get forward vector
const FVector Direction = FRotationMatrix(Rotation).GetUnitAxis(EAxis::X);
AddMovementInput(Direction, Value);
}
}
This line:
const FVector Direction = FRotationMatrix(Rotation).GetUnitAxis(EAxis::X);
Needs change to:
const FVector Direction = FRotationMatrix(YawRotation).GetUnitAxis(EAxis::X);