Files
M4_CPP/Source/M4_CPP/private/M4_PlayerPawn.cpp
CatChow0 f1cbe8c8c3 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.
2025-10-15 16:52:24 +02:00

56 lines
1.7 KiB
C++

// Fill out your copyright notice in the Description page of Project Settings.
#include "M4_PlayerPawn.h"
AM4_PlayerPawn::AM4_PlayerPawn()
{
PrimaryActorTick.bCanEverTick = true;
PrimaryActorTick.bStartWithTickEnabled = true;
SpawnCollisionHandlingMethod = ESpawnActorCollisionHandlingMethod::AlwaysSpawn;
RootComponent = CreateDefaultSubobject<USceneComponent>(TEXT("RootComponent"));
MeshComponent = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("MeshComponent"));
MeshComponent->SetMobility(EComponentMobility::Movable);
MeshComponent->SetCollisionEnabled(ECollisionEnabled::QueryAndPhysics);
MeshComponent->SetCollisionProfileName(UCollisionProfile::Pawn_ProfileName);
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)
{
PRINT_SCREEN(TEXT("DefaultMesh loaded"), FColor::Green);
}
else
{
PRINT_SCREEN(TEXT("Failed to load DefaultMesh"), FColor::Red);
}
}
void AM4_PlayerPawn::BeginPlay()
{
Super::BeginPlay();
if (MeshComponent && LoadedMesh)
{
PRINT_SCREEN(TEXT("LoadedMesh"), FColor::Green);
MeshComponent->SetStaticMesh(LoadedMesh);
}
}
void AM4_PlayerPawn::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
}