Paper2D Movement issue in C++

Hello Community :slight_smile:

I’m trying to move my pawn class via C++ and I am having an issue where setting the pawns position is not moving the character properly.

Here is my Code that moves the actor which is called in the Pawns Tick() function:



void ABasePlayerPawn::MoveHero(float const& deltaTime)
{
    FVector pos = GetActorLocation();

    UE_LOG(LogTemp, Warning, TEXT("Move Player (%f, %f)"),  HeroInput.MovementInput.X,  HeroInput.MovementInput.Y);
    pos.X += HeroInput.MovementInput.X * MoveSpeed * deltaTime;
    pos.Y += HeroInput.MovementInput.Y * MoveSpeed * deltaTime;

    SetActorLocation(pos);
}


When I press the W key, I expect the character to move Up on the screen, but it’s moving to the right as depicted in the image below:

Note:I ensured that pos.Y is changing and not pos.X.

I suspect this is caused by the camera, where the X-axis is actually vertical Below is my camera set up code:



    // Create a camera boom attached to the root (capsule)
    USpringArmComponent* CameraBoom = CreateDefaultSubobject<USpringArmComponent>(TEXT("CameraBoom"));
    CameraBoom->SetupAttachment(RootComponent);
    CameraBoom->TargetArmLength = 500.0f;
    CameraBoom->SocketOffset = FVector(0.0f, 0.0f, 0.0f);
    CameraBoom->bAbsoluteRotation = true;
    CameraBoom->bDoCollisionTest = false;
    CameraBoom->CameraRotationLagSpeed = false;
    CameraBoom->bUsePawnControlRotation = false;
    CameraBoom->SetWorldRotation(FRotator(-90.0f, 0.0f, 0.0f));


    // Create an orthographic camera (no perspective) and attach it to the boom
    TopViewCameraComponent = CreateDefaultSubobject<UCameraComponent>(TEXT("TopViewCamera"));
    TopViewCameraComponent->ProjectionMode = ECameraProjectionMode::Orthographic;
    TopViewCameraComponent->OrthoWidth = 2048.0f;
    TopViewCameraComponent->bUsePawnControlRotation = false;
    TopViewCameraComponent->SetupAttachment(CameraBoom, USpringArmComponent::SocketName);
    TopViewCameraComponent->SetWorldRotation(FRotator(-90.0f, 0.0f, 0.0f));


I tried changing the cameras orientation, but this still causes issues in the direction movement occurs. For example, if I rotate the camera 90 degrees on the X axis, the update and down movement works, but the Horizontal movement is inverted.

I am not sure what is the best way to resolve this issue.

Thanks for the help!