AActor::GetLifetimeReplicatedProps
#include "GameFramework/Actor.h"
Access: public
Specifiers: virtualoverride
Description
Override this in any actor subclass that has UPROPERTY members marked with Replicated or ReplicatedUsing to register those properties with the replication system.
Caveats & Gotchas
- • Always call `Super::GetLifetimeReplicatedProps(OutLifetimeProps)` first. Omitting the Super call silently drops all parent-class replicated properties, causing hard-to-diagnose desync.
- • Use `DOREPLIFETIME(AMyActor, MyProperty)` for unconditional replication, or `DOREPLIFETIME_CONDITION` for conditional variants (e.g. `COND_OwnerOnly`). Using the raw `OutLifetimeProps.Add()` API is error-prone.
- • This function is called once at registration time, not every frame. Changing conditions at runtime requires custom condition state via `GetReplicatedCustomConditionState`.
Signature
ENGINE_API virtual void GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const override; Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| OutLifetimeProps | TArray<FLifetimeProperty>& | Array to populate with the properties that should be replicated and their replication conditions. | — |
Return Type
void Example
Register replicated properties C++
#include "Net/UnrealNetwork.h"
void AMyActor::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const
{
Super::GetLifetimeReplicatedProps(OutLifetimeProps);
DOREPLIFETIME(AMyActor, Health);
DOREPLIFETIME_CONDITION(AMyActor, ShieldAmount, COND_OwnerOnly);
} Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?