APlayerState
#include "GameFramework/PlayerState.h" Description
Created for every player on a server (or in a standalone game) and replicated to all clients. Stores network-relevant player data such as name, score, ping, spectator status, and a reference to the controlled pawn.
Caveats & Gotchas
- • PlayerStates are always relevant by default and replicate to every client. In high player-count games, set bShouldUpdateReplicatedPing to false on states where ping display is not needed to reduce network overhead.
- • GetOwningController() returns null on clients for remote players — only the local player's PlayerState has a valid owning controller on the client.
- • APlayerState persists across seamless travel. Override CopyProperties() to carry custom subclass data across level transitions.
Example
Access PlayerState from a Pawn C++
APlayerState* PS = GetPlayerState();
if (PS)
{
FString Name = PS->GetPlayerName();
float Score = PS->GetScore();
} Events & Delegates
See Also
Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?