![]() |
UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
|
#include <PlayerState.h>
Inheritance diagram for APlayerState:Public Attributes | |
| uint8 | bHasBeenWelcomed:1 |
| uint8 | bUseCustomPlayerNames: 1 |
| TSubclassOf< class ULocalMessage > | EngineMessageClass |
| float | ExactPing |
| FString | SavedNetworkAddress |
| FName | SessionName |
| FOnPlayerStatePawnSet | OnPawnSet |
Protected Member Functions | |
| virtual ENGINE_API void | OverrideWith (APlayerState *PlayerState) |
| virtual ENGINE_API void | CopyProperties (APlayerState *PlayerState) |
| ENGINE_API void | ReceiveOverrideWith (APlayerState *OldPlayerState) |
| ENGINE_API void | ReceiveCopyProperties (APlayerState *NewPlayerState) |
| void | SetShouldUpdateReplicatedPing (bool bInShouldUpdateReplicatedPing) |
| virtual ENGINE_API void | HandleWelcomeMessage () |
Friends | |
| struct | FSetPlayerStatePawn |
A PlayerState is created for every player on a server (or in a standalone game). PlayerStates are replicated to all clients, and contain network game relevant information about the player, such as playername, score, etc.
| FUniqueNetIdRepl APlayerState::BP_GetUniqueId | ( | ) | const |
Gets the online unique id for a player. If a player is logged in this will be consistent across all clients and servers.
|
virtual |
Called by Controller when its PlayerState is initially replicated.
|
protectedvirtual |
Copy properties which need to be saved in inactive PlayerState
|
overridevirtual |
| void APlayerState::DispatchCopyProperties | ( | APlayerState * | PlayerState | ) |
| void APlayerState::DispatchOverrideWith | ( | APlayerState * | PlayerState | ) |
calls OverrideWith and triggers OnOverrideWith for BP extension
|
virtual |
Create duplicate PlayerState (for saving Inactive PlayerState)
|
inline |
Gets the literal value of the compressed Ping value (Ping = PingInMS / 4).
|
overridevirtual |
|
overridevirtual |
|
virtual |
returns previous player name
| class AController * APlayerState::GetOwningController | ( | ) | const |
Returns the AI or player controller that created this player state, or null for remote clients
|
inline |
Return the pawn controlled by this Player State.
|
inline |
Convenience helper to return a cast version of the pawn controlled by this Player State.
| float APlayerState::GetPingInMilliseconds | ( | ) | const |
Returns the ping (in milliseconds)
Returns ExactPing if available (local players or when running on the server), and the replicated CompressedPing (converted back to milliseconds) otherwise.
Note that replication of CompressedPing is controlled by bShouldUpdateReplicatedPing, and if disabled then this will return 0 or a stale value on clients for player states that aren't related to local players
| class APlayerController * APlayerState::GetPlayerController | ( | ) | const |
Return the player controller that created this player state, or null for remote clients
|
inline |
Gets the literal value of PlayerId.
| FString APlayerState::GetPlayerName | ( | ) | const |
returns current player name
|
virtual |
custom access to player name, called only when bUseCustomPlayerNames is set
|
inline |
Gets the literal value of Score.
|
inline |
Gets the literal value of StartTime.
|
inline |
Gets the literal value of UniqueId.
|
protectedvirtual |
called after receiving player name
|
inline |
Gets the literal value of bIsABot.
|
inline |
Gets the literal value of bFromPreviousLevel.
|
inline |
Gets the literal value of bIsInactive.
|
inline |
Gets the literal value of bOnlySpectator.
|
inline |
Gets the literal value of bIsSpectator.
|
virtual |
Called on the server when the owning player has disconnected, by default this method destroys this player state
|
virtual |
Called on the server when the owning player has reconnected and this player state is added to the active players array
|
virtual |
|
virtual |
|
virtual |
|
virtual |
Replication Notification Callbacks
|
virtual |
|
virtual |
Called on both the client and server when unique ID has been modified
|
protectedvirtual |
|
overridevirtual |
|
virtual |
Recalculates the replicated Ping value once per second (both clientside and serverside), based upon collected ping data
|
protected |
|
protected |
Register a player with the online subsystem
| bWasFromInvite | was this player invited directly |
|
overridevirtual |
|
virtual |
called by seamless travel when initializing a player on the other side - copy properties to the new PlayerState that should persist
Sets the value of CompressedPing without causing other side effects to this instance.
Sets the value of bIsABot without causing other side effects to this instance.
Sets the value of bFromPreviousLevel without causing other side effects to this instance.
Sets the value of bIsInactive without causing other side effects to this instance.
Sets the value of bOnlySpectator without causing other side effects to this instance.
Sets the value of bIsSpectator without causing other side effects to this instance.
|
virtual |
set the player name to S
Sets the value of PlayerId without causing other side effects to this instance.
|
virtual |
set the player name to S
|
virtual |
set the player name to S locally, does not trigger net updates
Sets the value of Score without causing other side effects to this instance.
|
inlineprotected |
Sets whether or not the replicated ping value is updated automatically.
Sets the value of StartTime without causing other side effects to this instance.
| void APlayerState::SetUniqueId | ( | const FUniqueNetIdRepl & | NewUniqueId | ) |
Associate an online unique id with this player
| InUniqueId | the unique id associated with this player |
| void APlayerState::SetUniqueId | ( | FUniqueNetIdRepl && | NewUniqueId | ) |
Associate an online unique id with this player
| InUniqueId | the unique id associated with this player |
Returns true if should broadcast player welcome/left messages. Current conditions: must be a human player a network game
|
virtual |
Unregister a player with the online subsystem
Receives ping updates for the client (both clientside and serverside), from the net driver NOTE: This updates much more frequently clientside, thus the clientside ping will often be different to what the server displays
|
friend |
| uint8 APlayerState::bHasBeenWelcomed |
client side flag - whether this player has been welcomed or not (player entered message)
| uint8 APlayerState::bUseCustomPlayerNames |
if set, GetPlayerName() will call virtual GetPlayerNameCustom() to allow custom access
| TSubclassOf<class ULocalMessage> APlayerState::EngineMessageClass |
This is used for sending game agnostic messages that can be localized
| float APlayerState::ExactPing |
Exact ping in milliseconds as float (rounded and compressed in replicated CompressedPing)
| FOnPlayerStatePawnSet APlayerState::OnPawnSet |
Broadcast whenever this player's possessed pawn is set
| FString APlayerState::SavedNetworkAddress |
Used to match up InactivePlayerState with rejoining playercontroller.
| FName APlayerState::SessionName |
The session that the player needs to join/remove from as it is created/leaves