AActor::ReplicateSubobjects
#include "GameFramework/Actor.h"
Access: public
Specifiers: virtual
Description
Override to manually replicate subobjects (UObjects owned by this actor) on the actor channel. Must return true if any data was written. Only called when bReplicateUsingRegisteredSubObjectList is false.
Caveats & Gotchas
- • Always call Super::ReplicateSubobjects() and OR its return value with your own — failure to do so skips component replication for the base class.
- • As of UE 5.1, the preferred approach is the Registered SubObject List (bReplicateUsingRegisteredSubObjectList=true + AddReplicatedSubObject), which makes this override unnecessary and avoids the boilerplate of manually tracking the channel.
- • The return value must be true if *any* subobject serialized data, even if most did not — returning false when data was written causes client corruption.
Signature
ENGINE_API virtual bool ReplicateSubobjects(class UActorChannel *Channel, class FOutBunch *Bunch, FReplicationFlags *RepFlags) Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| Channel | class UActorChannel * | The actor channel being used for replication. | — |
| Bunch | class FOutBunch * | The outgoing data bunch for this replication pass. | — |
| RepFlags | FReplicationFlags * | Flags controlling which conditions apply for this replication. | — |
Return Type
bool Example
Legacy manual subobject replication C++
bool AMyActor::ReplicateSubobjects(UActorChannel* Channel, FOutBunch* Bunch, FReplicationFlags* RepFlags)
{
bool bWroteSomething = Super::ReplicateSubobjects(Channel, Bunch, RepFlags);
if (IsValid(MySubobject))
{
bWroteSomething |= Channel->ReplicateSubobject(MySubobject, *Bunch, *RepFlags);
}
return bWroteSomething;
} Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?