Hi Community
I am having an issue where I believe the X-axis and Y-axis are not as I expect. When I move my character up my updating the actors position’s Y value, my character will move right or left instead of up or down.
I suspect there is an issue here with how the camera is orientated. I tried rotating the camera by 90 degrees on the X-axis, which will resolved the Y-axis issue, but my X-axis directions become inverses (+X value results in the pawn moving left stead of right). Below is the code for the movement and the camera set up. Any guidance on how to properly handle this issue would be much appreciated!
Camera Set Up:
// Create a camera boom attached to the root (capsule)
USpringArmComponent* CameraBoom = CreateDefaultSubobject(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));
Movement function called in Pawn Tick():
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);
}