Third Person Movement

Hi,

in the C++ template for third person, I wana change how the movement work

for example :

  • I want the pawn move backward instead of turning and move frontward
  • I wana the pawn make strafe instead of turning (right or left) and move frontward

Anny Ide where and how I can change that ?

Try looking in the code for the FPS C++ example in the wiki, or try replacing your character’s MoveForward() and MoveRight() methods with the following:

void ACharacter::MoveForward(float Value)
{
    if ( (Controller != NULL) && (Value != 0.0f) )
    {
        // find out which way is forward
        FRotator Rotation = Controller->GetControlRotation();

        // add movement in that direction
        const FVector Direction = FRotationMatrix(Rotation).GetScaledAxis(EAxis::X);
        AddMovementInput(Direction, Value);
    }
}

void ACharacter::MoveRight(float Value)
{
    if ( (Controller != NULL) && (Value != 0.0f) )
    {
        // find out which way is right
        const FRotator Rotation = Controller->GetControlRotation();
        const FVector Direction = FRotationMatrix(Rotation).GetScaledAxis(EAxis::Y);

        // add movement in that direction
        AddMovementInput(Direction, Value);
    }
}