
오늘은 언리얼 멀티플레이 환경에서 플레이어 카메라 시점이 보이지 않는 문제를 Activate로 해결한 과정과, 아직 남아 있는 카메라 회전(Input_Look) 문제를 원인 중심으로 정리하고자 합니다.
ACMPlayerCharacterBase 안에는 ViewCamera(UCameraComponent) 와 CameraBoom(USpringArmComponent) 가 존재CameraBoom->bUsePawnControlRotation = true;ViewCamera->bAutoActivate = false;ViewCamera->Activate() 를 호출해도 실제로 화면에 쓰이는 카메라는 GameplayCamera 이므로, 시점 문제는 그대로 유지NewPlayer->Possess(NewPawn) 실행BeginPlay 가 먼저 호출된 뒤에,PawnClientRestart/OnRep_Controller 등이 호출됨BeginPlay 기준으로 카메라 Setup 을 시도하면:IsLocallyControlled() 가 false 인 경우가 많음APawn::PawnClientRestart() 에서 가장 확실ACMPlayerCharacterBase 에 카메라 셋업 전용 헬퍼 함수 추가UGameplayCameraComponent 를 FindComponentByClass 로 찾아온다.Activate() (또는 SetupCamera()) 를 호출한다.PawnClientRestart() 에서:class UGameplayCameraComponent;
UCLASS()
class CRIMSONMOON_API ACMPlayerCharacterBase : public ACMCharacterBase
{
GENERATED_BODY()
// ...existing code...
private:
// BeginPlay 이후, 로컬 플레이어 기준으로 GameplayCamera를 셋업하는 헬퍼 함수
void SetupGameplayCamera_Helper();
// ...existing code...
};
void ACMPlayerCharacterBase::SetupGameplayCamera_Helper()
{
UE_LOG(LogTemp, Warning,
TEXT("SetupGameplayCamera_Helper: Called. IsLocallyControlled=%d"),
IsLocallyControlled() ? 1 : 0);
// 로컬 플레이어가 소유한 Pawn 에서만 카메라 셋업
if (!IsLocallyControlled())
{
UE_LOG(LogTemp, Warning,
TEXT("SetupGameplayCamera_Helper: Aborted - not locally controlled"));
return;
}
// BP 에서 추가된 UGameplayCameraComponent 를 찾아 SetupCamera/Activate 호출
if (UGameplayCameraComponent* GameplayCameraComp = FindComponentByClass<UGameplayCameraComponent>())
{
UE_LOG(LogTemp, Warning,
TEXT("SetupGameplayCamera_Helper: Found GameplayCameraComponent on %s, calling SetupCamera"),
*GetName());
// 현재는 Activate로 시점을 살려두었음 (필요 시 SetupCamera()로 교체 가능)
GameplayCameraComp->Activate();
// GameplayCameraComp->SetupCamera();
}
else
{
UE_LOG(LogTemp, Warning,
TEXT("SetupGameplayCamera_Helper: GameplayCameraComponent not found on %s"),
*GetName());
}
}
void ACMPlayerCharacterBase::PawnClientRestart()
{
Super::PawnClientRestart();
if (const APlayerController* OwningPlayerController = GetController<APlayerController>())
{
UEnhancedInputLocalPlayerSubsystem* PlayerSubsystem =
OwningPlayerController->GetLocalPlayer()->GetSubsystem<UEnhancedInputLocalPlayerSubsystem>();
check(PlayerSubsystem);
PlayerSubsystem->RemoveMappingContext(InputConfigDataAsset->DefaultMappingContext);
PlayerSubsystem->AddMappingContext(InputConfigDataAsset->DefaultMappingContext, 0);
}
// 로컬 클라이언트가 이 Pawn 을 다시 사용할 준비가 된 시점에 카메라 셋업 시도
SetupGameplayCamera_Helper();
}

Input_Look)에 따라 카메라가 상하좌우로 자연스럽게 회전해야 하는데,Input_Look 에서 AddControllerYawInput, AddControllerPitchInput 을 호출하고 있음bUsePawnControlRotation 설정이 비활성화되어 있거나,UGameplayCameraComponent Activate 로 해결이번 작업에서는 네트워크 환경에서 플레이어 카메라 시점이 비정상적으로 비춰지는 문제를, PawnClientRestart 시점에 UGameplayCameraComponent 를 찾아 Activate 하는 방식으로 해결하였습니다. 특히 BeginPlay, PossessedBy, PawnClientRestart 간의 호출 시점과 IsLocallyControlled() 여부가 네트워크 환경에서 어떻게 달라지는지 다시 한 번 정리할 수 있었고, 로컬 전용 카메라 로직은 PawnClientRestart 에서 처리하는 것이 안전하다는 점을 확인했습니다.
다만, 아직 마우스 입력에 따른 카메라 상하좌우 회전이 기대한 대로 동작하지 않는 문제가 남아 있습니다. 이는 C++ 단의 Input_Look 처리가 아니라, 실제 뷰를 담당하고 있는 GameplayCamera 컴포넌트의 회전 설정과 로직이 컨트롤러 회전을 어떻게 받아들이는지에 더 가깝기 때문에, 다음 단계에서는 해당 BP/컴포넌트의 bUsePawnControlRotation 설정, SpringArm 사용 여부, ViewTarget 세팅 방식을 집중적으로 점검하고 수정할 예정입니다.