Minor - Déplace la caméra vers le PlayerPawn - V01.04.00

Transfère la logique de la caméra du PlayerController vers le PlayerPawn.

Cela permet un meilleur contrôle et une association plus directe
de la caméra avec le pawn contrôlé.

Ajuste également les chemins de fichiers dans les macros
pour une meilleure organisation.
This commit is contained in:
2025-10-15 16:52:24 +02:00
parent 55a9234871
commit f1cbe8c8c3
5 changed files with 16 additions and 29 deletions

View File

@@ -6,28 +6,14 @@
AM4_PlayerController::AM4_PlayerController()
{
CameraComponent = CreateDefaultSubobject<UCameraComponent>(TEXT("CameraComponent"));
CameraComponent->ProjectionMode = ECameraProjectionMode::Orthographic;
CameraComponent->OrthoWidth = 2048.0f;
CameraComponent->SetAspectRatio(160.0f/192.0f);
// attach the camera to the controller's root component
CameraComponent->SetupAttachment(GetRootComponent());
PrimaryActorTick.bCanEverTick = false;
PrimaryActorTick.bStartWithTickEnabled = false;
}
void AM4_PlayerController::BeginPlay()
{
Super::BeginPlay();
if (CameraComponent)
{
CameraComponent->SetRelativeLocation(FVector(0, 0, 1000));
CameraComponent->SetRelativeRotation(FRotator(-90.0f, 0.0f, 0.0f));
// Set the camera as the view target
SetViewTarget(this);
}
if (!GetLocalPlayer())
{
@@ -105,13 +91,4 @@ void AM4_PlayerController::Move(const FInputActionValue& Value)
void AM4_PlayerController::OnPossess(APawn* InPawn)
{
Super::OnPossess(InPawn);
PRINT_SCREEN(TEXT("PlayerController Possess"), FColor::Green);
if (InPawn && CameraComponent)
{
CameraComponent->AttachToComponent(InPawn->GetRootComponent(), FAttachmentTransformRules::KeepRelativeTransform);
CameraComponent->SetRelativeLocation(FVector(0, 0, 1000));
CameraComponent->SetRelativeRotation(FRotator(-90.0f, 0.0f, 0.0f));
}
}

View File

@@ -18,6 +18,14 @@ AM4_PlayerPawn::AM4_PlayerPawn()
MeshComponent->SetRelativeScale3D(FVector(1.0f, 1.0f, 1.0f));
MeshComponent->SetupAttachment(RootComponent);
CameraComponent = CreateDefaultSubobject<UCameraComponent>(TEXT("CameraComponent"));
CameraComponent->ProjectionMode = ECameraProjectionMode::Orthographic;
CameraComponent->OrthoWidth = 2048.0f;
CameraComponent->SetAspectRatio(160.0f/192.0f);
CameraComponent->SetupAttachment(RootComponent);
CameraComponent->SetRelativeLocation(FVector(0,0,1000));
CameraComponent->SetRelativeRotation(FRotator(-90.0f, 0.0f, 0.0f));
LoadedMesh = DefaultMesh.LoadSynchronous();
if (LoadedMesh)
{