{ }Blueprint → C++

Unreal Engine 5 · Blueprint → C++

Replicated Variable in Unreal Engine 5 C++ (UPROPERTY Replicated)UE Docs

A Blueprint variable marked Replicated becomes a UPROPERTY(Replicated) in C++ that you register inside GetLifetimeReplicatedProps with the DOREPLIFETIME macro, with bReplicates = true set on the Actor.

Blueprint node & C++ equivalent

C++
// .h
UPROPERTY(Replicated)
int32 Health;

// .cpp
#include "Net/UnrealNetwork.h"
void AMyActor::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& Out) const
{
  Super::GetLifetimeReplicatedProps(Out);
  DOREPLIFETIME(AMyActor, Health);
}
// constructor: bReplicates = true;

What does a Replicated variable do?

Setting a variable to Replicated tells the server to push its value down to connected clients automatically whenever it changes on the authority. This keeps state like Health consistent across the network without writing manual sync code. Only the server should change the value; clients receive it.

The C++ equivalent

In the header, mark the member with UPROPERTY(Replicated), for example int32 Health;. Replication also requires registering the property, which Blueprints do for you but C++ does not.

Include Net/UnrealNetwork.h in the .cpp, then override GetLifetimeReplicatedProps, call Super::GetLifetimeReplicatedProps(Out), and add DOREPLIFETIME(AMyActor, Health);. Finally set bReplicates = true; in the constructor so the Actor replicates at all.

Common mistakes

Forgetting to override GetLifetimeReplicatedProps or omitting the DOREPLIFETIME line means the UPROPERTY(Replicated) marker is ignored and the value never reaches clients. Forgetting bReplicates = true; stops the Actor from replicating entirely. Always call Super::GetLifetimeReplicatedProps(Out) first so inherited properties continue to replicate.

Frequently asked questions

How do you replicate a variable in UE5 C++?+

Mark it UPROPERTY(Replicated), override GetLifetimeReplicatedProps, call DOREPLIFETIME(YourClass, YourVar), and set bReplicates = true in the constructor.

What does DOREPLIFETIME do in Unreal Engine?+

DOREPLIFETIME registers a property for lifetime replication inside GetLifetimeReplicatedProps. It is defined in Net/UnrealNetwork.h and is required for any UPROPERTY(Replicated) member to actually sync.

Why is my replicated variable not updating on clients?+

The most common causes are missing the DOREPLIFETIME registration, not setting bReplicates = true, or changing the value on a client instead of the server. Only the authority should write to a replicated variable.

Related Networking & Replication nodes

View all Networking & Replication nodes →