APlayerState::PostInitializeComponents
#include "GameFramework/PlayerState.h"
Access: public
Specifiers: virtualoverride
Description
Called after all components have been initialized. APlayerState uses this to register itself with the GameState's player array and to set initial values such as StartTime.
Caveats & Gotchas
- • Always call Super::PostInitializeComponents() when overriding. The base implementation registers the PlayerState with GameState::PlayerArray, which is required for the player to appear in scoreboard queries and other GameState lookups.
- • This runs before replication has begun on listen servers. If your override reads replicated data from other actors, it may be stale at this point.
- • PostInitializeComponents is called for every spawned PlayerState, including the inactive copies preserved across seamless travel. Check IsInactive() if your logic should only run for active players.
Signature
ENGINE_API virtual void PostInitializeComponents() override; Return Type
void Example
Initialize custom player stats after components are ready C++
void AMyPlayerState::PostInitializeComponents()
{
Super::PostInitializeComponents(); // MUST call Super
if (HasAuthority())
{
InitializeStats();
}
} Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?