GameMode 클래스- 총괄 관리자
- 플레이어 캐릭터 -pawn, character 클래스
- playerController 클래스 -캐릭터에 빙의
- 게임 규칙 관리 - 로직 함수, 점수의 규칙
- GameState 클래스-게임 전역 데이터-점수
- PlayerState 클래스 - 개별 캐릭터마다의 데이터
GameModeBase Vs. GameMode
- GameModeBase - 간단한 게임 위주
- GameMode - 다양한 기능 있음 (멀티플레이어)
GameMode 적용 2가지
- Project setting에서 적용(전역 적용, 모든 레벨)

2. Window - World Setting - GameMode -GameMode Override
레벨 지정이 1순위, 전역 적용 2순위
캐릭터 생성시 Pawn vs. Character
- Pawn - 상위 클래스, 하나하나 다 구현해줘야 함
- Character - 하위 클래스, 구현이 돼있음(이족 보행만 가능)
Character 클래스 생성하기
- ASpartaCharacter (ACharacter 상속):
- CapsuleComponent: 캐릭터의 물리적 충돌 범위 설정.
- SkeletalMeshComponent: 3D 모델 및 애니메이션 적용.
- SpringArm & Camera: 3인칭 시점 구현을 위해 필수. bUsePawnControlRotation 설정을 통해 컨트롤러 회전에 따른 카메라 제어 활성화.

#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Character.h"
#include "SpartaCharacter.generated.h"
class USpringArmComponent; // 스프링 암 관련 클래스 헤더
class UCameraComponent; // 카메라 관련 클래스 전방 선언
UCLASS()
class SPARTAPROJECT_API ASpartaCharacter : public ACharacter
{
GENERATED_BODY()
public:
ASpartaCharacter();
protected:
// 스프링 암 컴포넌트
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Camera")
USpringArmComponent* SpringArmComp;
// 카메라 컴포넌트
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Camera")
UCameraComponent* CameraComp;
virtual void SetupPlayerInputComponent(class UInputComponent*
PlayerInputComponent) override; // 이 함수는 이후에 다루게 되니, 우선 삭
제하기 않고 둡니다.
};
#include "SpartaCharacter.h"
// 카메라, 스프링 암 실제 구현이 필요한 경우라서 include
#include "Camera/CameraComponent.h"
#include "GameFramework/SpringArmComponent.h"
ASpartaCharacter::ASpartaCharacter()
{
// Tick 함수는 우선 꺼둡니다.
PrimaryActorTick.bCanEverTick = false;
// (1) 스프링 암 생성
SpringArmComp = CreateDefaultSubobject<USpringArmComponent>(TEXT("SpringArm"));
// 스프링 암을 루트 컴포넌트 (CapsuleComponent)에 부착
SpringArmComp->SetupAttachment(RootComponent);
// 캐릭터와 카메라 사이의 거리 기본값 300으로 설정
SpringArmComp->TargetArmLength = 300.0f;
SpringArmComp->bUsePawnControlRotation = true;
// (2) 카메라 컴포넌트 생성
CameraComp = CreateDefaultSubobject<UCameraComponent>(TEXT("Camera"));
// 스프링 암의 소켓 위치에 카메라를 부착
CameraComp->SetupAttachment(SpringArmComp, USpringArmComponent::SocketName);
// 카메라는 스프링 암의 회전을 따르므로 PawnControlRotation은 꺼둠
CameraComp->bUsePawnControlRotation = false;
}
void ASpartaCharacter::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
{
Super::SetupPlayerInputComponent(PlayerInputComponent);
}

3. 향상된 입력 시스템 (Enhanced Input System)
- Input Action (IA): '이동', '점프' 등 동작의 단위. Value Type을 통해 Bool, Axis1 D, Axis2D 등 데이터 형식을 지정.
- Input Mapping Context (IMC): IA와 실제 키보드/마우스 입력을 매핑. Swizzle 및 Negate 모디파이어를 사용하여 입력 축 방향을 보정.
- 활성화 로직: PlayerController에서 UEnhancedInputLocalPlayerSubsystem을 호출하여 런타임에 IMC를 추가함으로써 입력 활성화.
Value Type:
- Bool - 단순 on/off 토글 입력에 사용(점프, 공격)
- Axis1D - 단일 축 (가속페달, 전진/후진)
- Axis2D - X, Y 축 (캐릭터 이동, 마우스 이동)
- Axis3D - X, Y, Z 세 축 동시(비행 시뮬레이션)
트리거:
- Pressed Trigger - 키를 누르는 순간에만 작동
- Hold Trigger - 키를 일정 시간 눌렀을 때 작동
- Released Trigger - 키를 땔 때 작동
모디파이어
- Scale - 입력 값에 일정 배율을 곱해줌
- Invert - 입력 값을 반전
- DeadZone - 일정 임계값보다 작은 입력은 무시

#pragma once
#include "CoreMinimal.h"
#include "GameFramework/PlayerController.h"
#include "SpartaPlayerController.generated.h"
class UInputMappingContext; // IMC 관련 전방 선언
class UInputAction; // IA 관련 전방 선언
UCLASS()
class SPARTAPROJECT_API ASpartaPlayerController : public APlayerController
{
GENERATED_BODY()
public:
ASpartaPlayerController();
// 에디터에서 세팅할 IMC
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Input")
UInputMappingContext* InputMappingContext;
// IA_Move를 지정할 변수
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Input")
UInputAction* MoveAction;
// IA_Jump를 지정할 변수
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Input")
UInputAction* JumpAction;
// IA_Look를 지정할 변수
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Input")
UInputAction* LookAction;
// IA_Sprint를 지정할 변수
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Input")
UInputAction* SprintAction;
virtual void BeginPlay() override;
};
#include "SpartaPlayerController.h"
ASpartaPlayerController::ASpartaPlayerController()
: InputMappingContext(nullptr),
MoveAction(nullptr),
JumpAction(nullptr),
LookAction(nullptr),
SprintAction(nullptr)
{
}
void ASpartaPlayerController::BeginPlay()
{
Super::BeginPlay();
// 현재 PlayerController에 연결된 Local Player 객체를 가져옴
if (ULocalPlayer* LocalPlayer = GetLocalPlayer())
{
// Local Player에서 EnhancedInputLocalPlayerSubsystem을
획득
if (UEnhancedInputLocalPlayerSubsystem* Subsystem = LocalPlayer->GetSubsystem<UEnhancedInputLocalPlayerSubsystem>())
{
if (InputMappingContext)
{
// Subsystem을 통해 우리가 할당한 IMC를 활성화
// 우선순위(Priority)는 0이 가장 높은 우선순위
Subsystem->AddMappingContext(InputMappingContext,0);
}
}
}
}
'언리얼' 카테고리의 다른 글
| 역기획서: 리그오브레전드의 시야 시스템 분석 (1) | 2026.04.10 |
|---|---|
| 레인보우 식스 시즈 코어 루프 분석 및 MDA 적용 (0) | 2026.04.10 |
| 리플렉션/UHT/UBT/CDO (feat. Garbage Collection) (1) | 2026.04.10 |
| 언리얼C++) 액터 라이프사이클 (0) | 2026.04.08 |
| 언리얼C++) C++로 엑터 생성 (1) | 2026.04.07 |