概要
マルチプレイでの各環境ごとのControllerやLocalRole等の情報まとめです。
環境ごとに各項目がどの値になっているのかがいまいち分からず、マルチプレイ関連のソースコードを読むのが難しかったのでまとめました。
確認のためにゲーム画面に各Pawnの情報を表示する検証用C++
プロジェクトを作成し、GitHubにアップロードしました。
※Dedicated Serverはゲーム画面がないのでログ出力
ogamita777/DisplayRole
何かしら気になる方は、ダウンロードして手元で試していただければと思います。
■環境
- UnrealEngine:5.5.2
- ビルド構成:DebugGame Editor
■ゲームプレイ設定
- Multiplayer Options
- Run Under One Process:true
- Client
- Play Number Of Clients(Number of Players):3
Play As ListenServer(ListenServer)のとき
■Server0環境(左上)
プレイヤー1 | プレイヤー2 | プレイヤー3 | 備考 | |
---|---|---|---|---|
PlayerState->GetPlayerId() | 256 | 257 | 258 | 各環境で同じ値 |
Pawn | BP_TestPlayer_C_0 | BP_TestPlayer_C_1 | BP_TestPlayer_C_2 | |
Controller | PlayerController_0 | PlayerController_1 | PlayerController_2 | |
Controller->IsLocalController() | true | false | false | |
Controller->GetNetMode() | NM_ListenServer | NM_ListenServer | NM_ListenServer | |
LocalRole | Authority | Authority | Authority | |
RemoteRole | Simulated Proxy | Autonomous Proxy | Autonomous Proxy |
■Client1環境(右上)
プレイヤー1 | プレイヤー2 | プレイヤー3 | 備考 | |
---|---|---|---|---|
PlayerState->GetPlayerId() | 256 | 257 | 258 | 各環境で同じ値 |
Pawn | BP_TestPlayer1 | BP_TestPlayer0 | BP_TestPlayer2 | |
Controller | nullptr | PlayerController1 | nullptr | |
Controller->IsLocalController() | - | true | - | |
Controller->GetNetMode() | - | NM_Client | - | |
LocalRole | Simulated Proxy | Autonomous Proxy | Simulated Proxy | |
RemoteRole | Authority | Authority | Authority |
■Client2環境(左下)
プレイヤー1 | プレイヤー2 | プレイヤー3 | 備考 | |
---|---|---|---|---|
PlayerState->GetPlayerId() | 256 | 257 | 258 | 各環境で同じ値 |
Pawn | BP_TestPlayer_C_1 | BP_TestPlayer_C_2 | BP_TestPlayer_C_0 | |
Controller | nullptr | nullptr | PlayerController_1 | |
Controller->IsLocalController() | - | - | true | |
Controller->GetNetMode() | - | - | NM_Client | |
LocalRole | Simulated Proxy | Simulated Proxy | Autonomous Proxy | |
RemoteRole | Authority | Authority | Authority |
Play As Client(Dedicated Server)のとき
■Server環境(ログ出力)
プレイヤー1 | プレイヤー2 | プレイヤー3 | 備考 | |
---|---|---|---|---|
PlayerState->GetPlayerId() | 256 | 257 | 258 | 各環境で同じ値 |
Pawn | BP_TestPlayer_C_0 | BP_TestPlayer_C_1 | BP_TestPlayer_C_2 | |
Controller | PlayerController_0 | PlayerController_1 | PlayerController_2 | |
Controller->IsLocalController() | false | false | false | |
Controller->GetNetMode() | NM_DedicatedServer | NM_DedicatedServer | NM_DedicatedServer | |
LocalRole | Authority | Authority | Authority | |
RemoteRole | Autonomous Proxy | Autonomous Proxy | Autonomous Proxy |
■Client1環境(右上)
プレイヤー1 | プレイヤー2 | プレイヤー3 | 備考 | |
---|---|---|---|---|
PlayerState->GetPlayerId() | 256 | 257 | 258 | 各環境で同じ値 |
Pawn | BP_TestPlayer0 | BP_TestPlayer1 | BP_TestPlayer2 | |
Controller | PlayerController1 | nullptr | nullptr | |
Controller->IsLocalController() | true | - | - | |
Controller->GetNetMode() | NM_Client | - | - | |
LocalRole | Autonomous Proxy | Simulated Proxy | Simulated Proxy | |
RemoteRole | Authority | Authority | Authority |
■Client2環境(左下)
プレイヤー1 | プレイヤー2 | プレイヤー3 | 備考 | |
---|---|---|---|---|
PlayerState->GetPlayerId() | 256 | 257 | 258 | 各環境で同じ値 |
Pawn | BP_TestPlayer_C_1 | BP_TestPlayer_C_0 | BP_TestPlayer_C_2 | |
Controller | nullptr | PlayerController_1 | nullptr | |
Controller->IsLocalController() | - | true | - | |
Controller->GetNetMode() | - | NM_Client | - | |
LocalRole | Simulated Proxy | Autonomous Proxy | Simulated Proxy | |
RemoteRole | Authority | Authority | Authority |
■Client3環境(右下)
プレイヤー1 | プレイヤー2 | プレイヤー3 | 備考 | |
---|---|---|---|---|
PlayerState->GetPlayerId() | 256 | 257 | 258 | 各環境で同じ値 |
Pawn | BP_TestPlayer_C_2 | BP_TestPlayer_C_1 | BP_TestPlayer_C_0 | |
Controller | nullptr | nullptr | PlayerController_1 | |
Controller->IsLocalController() | - | - | true | |
Controller->GetNetMode() | - | - | NM_Client | |
LocalRole | Simulated Proxy | Simulated Proxy | Autonomous Proxy | |
RemoteRole | Authority | Authority | Authority |
気になる箇所
- 同じPawnやControllerだったとしても環境ごとに名前(
GetActorNameOrLabel()
)が異なっている- 例:ListenServerのServer0環境ではPawnは
BP_TestPlayer_C_0
であるが、Client1環境だとBP_TestPlayer1
-
GetActorNameOrLabel()
の値が同期はされていないため。生成順で名前が設定されるっぽい
- 例:ListenServerのServer0環境ではPawnは
- 同環境でPawnとControllerの後ろに付いている数字が一致しているのはサーバー環境のみ(※これも不定?)。クライアント環境では数字が違う
- 例:ListenServerのClient1環境ではPawnは
BP_TestPlayer0
、ControllerはPlayerController1
- 把握していないとクライアント環境でデバッグしたときに誤解しそう
- 例:ListenServerのClient1環境ではPawnは
検証用プロジェクトについて
PawnとしてBP_TestPlayerが生成されます。
最低限の操作が可能です。
■操作方法
- 移動:WASD
- カメラ操作:マウス
■実装について
DisplayRole\Source\DisplayRole\Private\Player\TestPlayer.cpp
ATestPlayer::DisplayDebug()
で各種情報をゲーム画面に表示する実装を行っております。