APlayerState

Inheritance Hierarchy

Syntax

class APlayerState : public AInfo

Remarks

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.

Functions

Name Description

Public function Virtual

void

 

ClientInitialize

(
    AController* C
)

Called by Controller when its PlayerState is initially replicated.

Protected function Virtual

void

 

CopyProperties

(
    APlayerState * PlayerState
)

Copy properties which need to be saved in inactive PlayerState

Public function

void

 

DispatchCopyProperties

(
    APlayerState * PlayerState
)

Public function

void

 

DispatchOverrideWith

(
    APlayerState * PlayerState
)

Calls OverrideWith and triggers OnOverrideWith for BP extension

Public function Virtual

APlayerState ...

 

Duplicate()

Create duplicate PlayerState (for saving Inactive PlayerState)

Public function Virtual

bool

 

IsPrimaryPlayer()

Return true if PlayerState is primary (ie. non-splitscreen) player

Public function Virtual

void

 

OnDeactivated()

Called on the server when the owning player has disconnected, by default this method destroys this player state

Public function Virtual

void

 

OnReactivated()

Called on the server when the owning player has reconnected and this player state is added to the active players array

Public function Virtual

void

 

OnRep_bIsInactive()

Public function Virtual

void

 

OnRep_PlayerName()

Public function Virtual

void

 

OnRep_Score()

Replication Notification Callbacks

Public function Virtual

void

 

OnRep_UniqueId()

Protected function Virtual

void

 

OverrideWith

(
    APlayerState * PlayerState
)

Public function Virtual

void

 

RecalculateAvgPing()

Recalculates the replicated Ping value once per second (both clientside and serverside), based upon collected ping data

Protected function

void

 

ReceiveCopyProperties

(
    APlayerState * NewPlayerState
)

Can be implemented in Blueprint Child to move more properties from old to new PlayerState when traveling to a new level

Protected function

void

 

ReceiveOverrideWith

(
    APlayerState * OldPlayerState
)

Can be implemented in Blueprint Child to move more properties from old to new PlayerState when reconnecting

Public function Virtual

void

 

RegisterPlayerWithSession

(
    bool bWasFromInvite
)

Register a player with the online subsystem

Public function Virtual

void

 

SeamlessTravelTo

(
    APlayerState * NewPlayerState
)

Called by seamless travel when initializing a player on the other side - copy properties to the new PlayerState that should persist

Public function Virtual

void

 

SetPlayerName

(
    const FString & S
)

Set the player name to S

Public function Virtual

void

 

SetUniqueId

(
    const TSharedPtr < const FUniqueNetI ...
)

Associate an online unique id with this player

Public function Virtual

bool

 

ShouldBroadCastWelcomeMessage

(
    bool bExiting
)

Returns true if should broadcast player welcome/left messages.

Public function Virtual

void

 

UnregisterPlayerWithSession()

Unregister a player with the online subsystem

Public function Virtual

void

 

UpdatePing

(
    float InPing
)

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

Overridden from AActor

Name Description

Public function Virtual

void

 

Destroyed()

Called once this actor has been deleted

Public function Virtual

FString

 

GetHumanReadableName()

Returns the human readable string representation of an object.

Public function Virtual

void

 

PostInitializeComponents()

Allow actors to initialize themselves on the C++ side.

Public function Virtual

void

 

Reset()

Reset actor to initial state - used when restarting level without reloading.

References

Module

Engine

Header

Runtime/Engine/Classes/GameFramework/PlayerState.h