RealDocs

AGameStateBase::GetLifetimeReplicatedProps

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

Description

Registers which UPROPERTY members are replicated and under what conditions. Override this in your GameState subclass to add replication rules for any new UPROPERTY(Replicated) fields you declare.

Caveats & Gotchas

  • You must call Super::GetLifetimeReplicatedProps(OutLifetimeProps) in your override, or the engine's own replicated properties (PlayerArray, bReplicatedHasBegunPlay, ReplicatedWorldTimeSecondsDouble, etc.) will stop replicating — a subtle and hard-to-diagnose bug.
  • This function is called once during actor initialization to build the replication layout. Changing the OutLifetimeProps contents at runtime (e.g., conditionally omitting a property) is not supported — the layout is fixed. Use DOREPLIFETIME_CONDITION for conditional replication.
  • A common mistake is adding UPROPERTY(Replicated) to a field but forgetting to register it here. The property will appear to replicate in PIE (where server and client share memory) but silently fail in a packaged build or dedicated server scenario.

Signature

ENGINE_API virtual void GetLifetimeReplicatedProps(TArray< FLifetimeProperty > &OutLifetimeProps) const;

Parameters

Name Type Description Default
OutLifetimeProps TArray< FLifetimeProperty >& Output array to which replicated property descriptors are appended.

Return Type

void

Example

Register custom replicated properties C++
void AMyGameState::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const
{
    Super::GetLifetimeReplicatedProps(OutLifetimeProps);
    DOREPLIFETIME(AMyGameState, TeamScores);
    DOREPLIFETIME(AMyGameState, RoundNumber);
    DOREPLIFETIME_CONDITION(AMyGameState, ServerSideData, COND_ServerOnly);
}

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.