RealDocs

UActorComponent::ReplicateSubobjects

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

Description

Legacy virtual called by the networking system to replicate any UObject subobjects owned by this component. Only used when bReplicateUsingRegisteredSubObjectList is false.

Caveats & Gotchas

  • This method is bypassed entirely when bReplicateUsingRegisteredSubObjectList is true — use AddReplicatedSubObject/RemoveReplicatedSubObject instead, which is the preferred modern approach as of UE 5.
  • Must return true if any subobject was written to the bunch. Returning an incorrect value causes incomplete replication updates or unnecessary bandwidth usage.

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 this replication is going through.
Bunch class FOutBunch* The outgoing data bunch being written.
RepFlags FReplicationFlags* Flags controlling which clients receive this replication.

Return Type

bool

Example

Legacy subobject replication override C++
bool UMyComponent::ReplicateSubobjects(UActorChannel* Channel, FOutBunch* Bunch, FReplicationFlags* RepFlags)
{
	bool bWroteSomething = Super::ReplicateSubobjects(Channel, Bunch, RepFlags);
	if (MySubObject && MySubObject->IsSupportedForNetworking())
	{
		bWroteSomething |= Channel->ReplicateSubobject(MySubObject, *Bunch, *RepFlags);
	}
	return bWroteSomething;
}

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.