Get Game Mode / Get Game State / Get Player State¶
At a glance
Lives in: Blueprint API / Game; implemented by Gameplay Statics -
Returns: GameModeBase, GameStateBase, or PlayerState references;
each can be None - Fails by: returning None, or by returning a
base-class object that your cast rejects - Official docs:
Get Game Mode,
Get Game State,
Get Player State,
and Get Num Player States
The one-minute version¶
Get Game Modereturns the current level'sGameModeBaseobject on the machine that has one. In multiplayer, that usually means the server only.Get Game Statereturns the currentGameStateBaseobject for this world. This is the public match/session state object clients are supposed to read.Get Player Statereturns an entry from the GameState'sPlayerArrayby index. It is for public connected-player records, not local input ownership.- The returned pin is typed to a base class. Your actual object can be
BP_MatchGameMode,BP_MatchGameState, orBP_MatchPlayerState; cast when you need your project's variables. Get Player State(0)is not the same question asGet Player Controller(0). PlayerState is replicated public player data. PlayerController is input/UI/control ownership and does not exist for every remote player on every client.- These nodes do not create the framework objects, wait for replication, or repair a wrong Maps & Modes setup. They only read the references that exist right now.
What they actually do¶
These are world-context getters. Blueprint hides the first input: "which world is this graph running in?" Once Unreal has the current world, the nodes ask for framework objects that world already owns.
flowchart LR
World[Current world] --> GM[GameMode<br/>server rules]
World --> GS[GameState<br/>public match state]
GS --> PA[PlayerArray]
PA --> PS0[PlayerState 0]
PA --> PS1[PlayerState 1]
The behavior is roughly:
pseudocode of the engine behavior - not engine source
function GetGameMode(WorldContext):
World = find the world from WorldContext
return World.AuthGameMode, or None
function GetGameState(WorldContext):
World = find the world from WorldContext
return World.GameState, or None
function GetPlayerState(WorldContext, PlayerStateIndex):
GameState = GetGameState(WorldContext)
if GameState is None:
return None
return GameState.PlayerArray[PlayerStateIndex], or None
The important split is audience:
- GameMode is where the rules decide things: restart players, award score, start/end the match, choose default classes.
- GameState is where public match state is visible: phase, timer, objective summary, team score.
- PlayerState is where public per-player state is visible: score, team, name, ready state, deaths, public loadout summary.
That framework split is explained in GameMode & friends and GameState and PlayerState in practice.
When they fail (and what failure does)¶
All three nodes can return None.
Common causes:
- You asked for GameMode on a remote client. Remote clients do not have the server's authoritative GameMode actor. Use GameState/PlayerState for state clients should display.
- The world is not ready yet. Construction Script, very early startup, or editor preview contexts can run before the framework object you expect is available.
- The active map uses a different class. The getter succeeds, but your
Cast To BP_MatchGameStatefails because Maps & Modes or the map override still points at the default class. - The PlayerState index does not exist. Index
5in a two-player session returnsNone. UseGet Num Player States,PlayerArray, or known PlayerState references instead of guessing. - Replication has not delivered all PlayerStates yet. After initial
replication, clients can read PlayerStates for connected players, but early
UI setup may still need to handle
Noneand refresh later. - You confused PlayerState index with local player index. The order is a GameState player array lookup, not "the controller using this keyboard."
Failure has no hidden recovery. The nodes do not spawn a missing GameMode,
switch the active GameMode class, create a PlayerState, retry next frame, or
log a guaranteed warning. You get a reference or None, and your graph must
decide what to do.
Use Is Valid before reading the result when timing, travel, respawn, or multiplayer replication can make the reference empty.
The pattern everyone actually uses¶
For single-player rules running in GameMode:
BP_MatchGameMode AwardScore
-> Get Game State
-> Cast To BP_MatchGameState
-> update MatchScore / ObjectiveSummary
For a HUD that needs public match state:
PlayerController creates HUD
-> Get Game State
-> Cast To BP_MatchGameState
-> bind to local update dispatcher or call RefreshFromGameState
For a scoreboard:
Scoreboard widget opens
-> Get Game State
-> PlayerArray
-> ForEach PlayerState
-> Cast To BP_MatchPlayerState
-> build rows from public replicated values
For the owning player only:
Get Player Controller (0)
-> Player State property / Get Player State from the controller
-> Cast To BP_MatchPlayerState
-> update local personal score text
That last pattern starts from the local controller because the widget wants the
owning player's record. It is not the GameplayStatics Get Player
State(index) list lookup. The scoreboard pattern starts from GameState because
it wants every public player record.
The C++ twin, for the curious (our own example code):
void UMatchHudWidget::RefreshScoreboard()
{
UWorld* World = GetWorld();
if (!World)
{
return;
}
AGameStateBase* GameState = World->GetGameState();
if (!IsValid(GameState))
{
return;
}
for (APlayerState* PlayerState : GameState->PlayerArray)
{
if (!IsValid(PlayerState))
{
continue;
}
AddScoreboardRow(PlayerState);
}
}
Why Get Player State(index) is not Get Player Controller(index)¶
They both take an index, but they are indexing different lists for different audiences.
| Question | Getter | Beginner translation |
|---|---|---|
| "Which local player owns this input/UI/camera path?" | Get Player Controller(index) |
Local player slot / available controller on this machine. |
| "Which public player record is in the replicated match list?" | Get Player State(index) |
Entry in GameState's PlayerArray after replication. |
In networked play, clients usually do not have other players' PlayerController actors. They do have replicated PlayerStates. That is why scoreboards, nameplates, team colors, and public scores read PlayerState rather than searching for every PlayerController.
For a first single-player project, both index 0 calls may seem to point at
"me." Do not build that habit into multiplayer UI. Start from the object that
matches the question.
Lookalikes - which one do I want?¶
| Node or object | Returns | Use when |
|---|---|---|
| Get Game Mode | GameModeBase or None |
Server/authority rules need the active rules object. Not client UI. |
| Get Game State | GameStateBase or None |
UI, clients, or shared logic need public match/session state. |
| Get Player State(index) | PlayerState or None |
You need one replicated public player record from the GameState list. |
| Get Num Player States | integer count | You need to iterate valid PlayerState indexes. |
| Controller PlayerState property | that controller's PlayerState, or None |
You already have the PlayerController and need its player record. |
| Get Player Controller(index) | PlayerController or None |
You need local input, camera, UI ownership, or an owned RPC path. |
| Get Player Pawn / Character | current player body or None |
You need the pawn/character currently possessed by a player slot. |
| GameInstance | local object that survives Open Level | Data should survive map travel on this process, not replicate as match state. |
| SaveGame | disk-backed data object | Data should survive quitting and relaunching. |
| Get Actor Of Class | some world actor | You are looking for a placed/spawned actor, not a framework object. |
Rule of thumb: GameMode decides on the server, GameState announces match state, PlayerState announces public player state, PlayerController owns local input/UI, and Pawn is the current body.
Going deeper¶
- GameMode & friends, single-player edition
- active GameMode selection, default classes, and spawn flow.
- GameState and PlayerState in practice
- public match/player state in multiplayer.
- Score, objectives, and win/loss state
- deciding rules in GameMode and exposing public results through state.
- Get Player Character / Pawn / Controller
- player-slot getters and why controller lists differ by machine.
- Is Valid - guard
Noneand destroyed object references before reading custom variables. - Official docs: Get Game Mode, Get Game State, Get Player State, Get Num Player States, Game Mode and Game State, and UGameplayStatics.
- Engine source (requires engine access - we do not reproduce it here):
UGameplayStatics::GetGameMode,UGameplayStatics::GetGameState,UGameplayStatics::GetPlayerState, andUGameplayStatics::GetNumPlayerStatesinEngine/Source/Runtime/Engine/Private/GameplayStatics.cpp; declarations inEngine/Source/Runtime/Engine/Classes/Kismet/GameplayStatics.h.