RealDocs

UActorComponent::GetLifetimeReplicatedProps

function Engine Since 4.0
#include "Components/ActorComponent.h"
Access: public Specifiers: virtualoverride

Description

Registers which UPROPERTY members should be replicated and under what conditions. Override this and use DOREPLIFETIME macros to declare replicated properties.

Caveats & Gotchas

  • Always call Super::GetLifetimeReplicatedProps(OutLifetimeProps) first so the base class registers its own replicated properties (e.g. bIsActive).
  • Properties added here are only actually replicated if the component itself has bReplicates = true and the owning actor replicates.
  • Conditional replication rules (DOREPLIFETIME_CONDITION) are evaluated on the server; misusing conditions can lead to clients receiving stale values.

Signature

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

Parameters

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

Return Type

void

Example

Replicating a custom property C++
#include "Net/UnrealNetwork.h"

void UMyComponent::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const
{
	Super::GetLifetimeReplicatedProps(OutLifetimeProps);
	DOREPLIFETIME(UMyComponent, Health);
	DOREPLIFETIME_CONDITION(UMyComponent, ShieldValue, COND_OwnerOnly);
}

Version History

Introduced in: 4.0

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.