NetRole은 존재하는 Actor의 권한 상태를 현재 실행 중인 머신에서 표현
| 구분 | 기준 | 예시 |
|---|---|---|
NetMode |
현재 World가 서버인지 클라이언트인지 | NM_Client, NM_ListenServer |
NetRole |
현재 Actor가 권한자인지 복제본인지 | ROLE_Authority, ROLE_AutonomousProxy |
멀티플레이에서는 같은 Actor 클래스의 코드가 서버와 클라이언트 양쪽에서 실행될 수 있다.
그래서 특정 Actor의 함수가 서버 권한으로 실행 중인지, 클라이언트 복제본에서 실행 중인지를 구분해야 한다.
Local Role과 Remote Role
LocalRole은 현재 머신에서 이 Actor가 가진 Role이다.
RemoteRole은 네트워크 반대편에서 이 Actor가 가진 Role이다.
| 구분 | 의미 |
|---|---|
LocalRole |
현재 코드가 실행 중인 머신에서의 Actor 역할 |
RemoteRole |
연결된 반대편 머신에서의 Actor 역할 |
예를 들어 서버에 있는 플레이어 Pawn은 서버 입장에서는 Authority다.
그 Pawn은 소유 클라이언트 입장에서는 AutonomousProxy로 존재한다.
| 위치 | LocalRole | RemoteRole |
|---|---|---|
| 서버의 플레이어 Pawn | ROLE_Authority |
ROLE_AutonomousProxy |
| 소유 클라이언트의 내 Pawn | ROLE_AutonomousProxy |
ROLE_Authority |
| 다른 클라이언트의 친구 Pawn | ROLE_SimulatedProxy |
ROLE_Authority |
NetRole 종류
| Role | 의미 | 대표 예시 |
|---|---|---|
ROLE_None |
복제되지 않거나 네트워크 Role이 없는 상태 | 서버 전용 Actor, 로컬 전용 Actor |
ROLE_Authority |
게임 상태를 결정할 권한을 가진 원본 Actor | 서버의 Actor, GameMode |
ROLE_AutonomousProxy |
소유 클라이언트가 조작 가능한 복제본 | 내 PlayerController, 내 Pawn |
ROLE_SimulatedProxy |
서버 상태를 수신받아 시뮬레이션하는 복제본 | 내 화면의 다른 플레이어 Character |
BeginPlay와 PossessedBy 로그
BeginPlay()는 서버와 클라이언트 양쪽에서 실행될 수 있다.PossessedBy()는 서버에서 Pawn이 Controller에 의해 Possess될 때 호출된다.
| 함수 | 주로 확인할 것 |
|---|---|
BeginPlay() |
이 Actor가 서버와 클라이언트 어디에서 생성되었는지 |
PossessedBy() |
서버에서 어떤 Controller가 Pawn을 소유했는지 |
GetLocalRole() |
현재 머신의 Actor 권한 |
GetRemoteRole() |
반대편에서의 Actor 권한 |
FString CombinedString = FString::Printf(
TEXT("CXPawn::BeginPlay() %s [%s]"),
*GetNetModeString(this),
*GetRoleString(this)
);
로그에 NetMode와 NetRole을 같이 찍으면 현재 코드가 어느 머신에서 어떤 권한으로 실행되는지 확인하기 쉽다.
Actor별 Role 특징
| Actor | 서버 | 소유 클라이언트 | 다른 클라이언트 |
|---|---|---|---|
GameMode |
Authority |
존재하지 않음 | 존재하지 않음 |
GameState |
Authority |
SimulatedProxy |
SimulatedProxy |
PlayerController |
Authority |
AutonomousProxy |
존재하지 않음 |
PlayerState |
Authority |
SimulatedProxy |
SimulatedProxy |
| 내 Pawn | Authority |
AutonomousProxy |
SimulatedProxy |
| 다른 플레이어 Pawn | Authority |
SimulatedProxy |
AutonomousProxy on owner |
| 일반 Replicated Actor | Authority |
SimulatedProxy |
SimulatedProxy |
LocalRole과 RemoteRole 차이
LocalRole만 있으면 서버에 있는 여러 Authority Actor를 구분하기 어렵다.
예시:
| Actor | 서버 LocalRole |
|---|---|
| 클라이언트가 조작하는 캐릭터 A | Authority |
| 서버에서만 스폰한 캐릭터 B | Authority |
둘 다 서버에서는 Authority다.
RemoteRole까지 보면 구분할 수 있다.
| Actor | 서버 LocalRole | 서버 RemoteRole | 의미 |
|---|---|---|---|
| 클라이언트가 조작하는 캐릭터 A | Authority |
AutonomousProxy |
소유 클라이언트가 조작하는 Actor |
| 서버에서만 스폰한 캐릭터 B | Authority |
None |
클라이언트로 복제되지 않는 Actor |
| 서버에서 복제하는 일반 Actor | Authority |
SimulatedProxy |
클라이언트에서 보기만 하는 Actor |
서버에서 Client RPC를 보내거나 Owner-only Replication을 처리하려면 해당 Actor가 어떤 클라이언트와 연결되는지 구분해야 한다.
NetMode와 NetRole 함께 보기
| 구분 | 확인 대상 | 질문 |
|---|---|---|
NetMode |
World / Process | 지금 이 코드는 서버 프로세스에서 도는가, 클라이언트 프로세스에서 도는가 |
LocalRole |
Actor | 현재 머신에서 이 Actor는 Authority인가 Proxy인가 |
RemoteRole |
Actor | 반대편에서 이 Actor는 어떤 Role인가 |
HasAuthority() |
Actor | 이 Actor의 상태를 확정할 권한이 있는가 |
IsLocalController() |
Controller | 이 Controller가 현재 머신의 로컬 Controller인가 |
IsLocallyControlled() |
Pawn | 이 Pawn이 현재 머신에서 로컬 조작 대상인가 |
반응형
'TIL' 카테고리의 다른 글
| UE Angel Script 문법 (0) | 2026.08.05 |
|---|---|
| Unreal Engine Angel Script (0) | 2026.08.03 |
| UE Authority (0) | 2026.07.30 |
| MyaCat 발표 후 회고 (0) | 2026.07.24 |
| World Partition (0) | 2026.07.23 |