RealDocs

AGameStateBase::PostInitializeComponents

function Engine Since 4.14
#include "GameFramework/GameStateBase.h"
Access: public Specifiers: virtualoverride

Description

Called after all components have been initialized. The GameStateBase implementation starts the periodic server-time update timer so that replicated world time stays synchronized with clients.

Caveats & Gotchas

  • The server-time sync timer (UpdateServerTimeSeconds) is started here. If you override PostInitializeComponents without calling Super, clients will not receive synchronized world time — GetServerWorldTimeSeconds will return stale values.
  • GameStateBase does not call InitGameState from here; that is called by the GameMode in PreInitializeComponents. PostInitializeComponents on the GameState runs afterward and is safe to access GameMode state, but the GameMode may not yet be fully initialized.
  • This fires on both server and client. On clients, components are initialized when the replicated GameState actor is first received, which may be several seconds into the session. Do not place match-setup logic here that should only run once.

Signature

ENGINE_API virtual void PostInitializeComponents() override;

Return Type

void

Example

Initialize a server-only resource after components are ready C++
void AMyGameState::PostInitializeComponents()
{
    Super::PostInitializeComponents();
    if (HasAuthority())
    {
        // Only run on server
        InitializeLeaderboard();
    }
}

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.