RealDocs

AGameStateBase::PlayerArray

property Engine Blueprint Since 4.14
#include "GameFramework/GameStateBase.h"
Access: public Specifiers: UPROPERTYTransientBlueprintReadOnly

Description

The authoritative list of all connected PlayerStates, maintained on both server and clients. PlayerStates are always network-relevant so this array stays in sync automatically.

Caveats & Gotchas

  • Do not add or remove entries manually — use `AddPlayerState` / `RemovePlayerState`. Direct mutation can desync the array from the PlayerState's own back-reference.
  • The array may briefly contain stale entries for players who are disconnecting; always null-check each element before use.

Signature

UPROPERTY(Transient, BlueprintReadOnly, Category=GameState)
TArray<TObjectPtr<APlayerState>> PlayerArray

Examples

Iterate all connected players and print their names Blueprint
Event BeginPlay Get Game State Return Value Get Player Array Target is Game State Base Target Player Array For Each Loop Array Loop Body Array Element Array Index Completed Get Player Name Target is Player State Target Return Value Print String In String Duration 2.0
Edit Blueprint graph Iterate all connected players and print their names
Drag node headers to move · Drag from an output pin to an input pin to connect · Scroll to zoom · Right-click for actions
Iterate all connected players C++
if (AGameStateBase* GS = GetWorld()->GetGameState())
{
    for (APlayerState* PS : GS->PlayerArray)
    {
        if (PS)
        {
            UE_LOG(LogTemp, Log, TEXT("Player: %s"), *PS->GetPlayerName());
        }
    }
}

Version History

Introduced in: 4.14

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.