UActorComponent::AddReplicatedSubObject
#include "Components/ActorComponent.h"
Access: public
Description
Registers a UObject subobject to be replicated alongside this component using the registered subobject list. This is the preferred alternative to overriding ReplicateSubobjects.
Caveats & Gotchas
- • The owning actor must have bReplicateUsingRegisteredSubObjectList set to true for this to take effect; calling it on an actor that still uses the legacy ReplicateSubobjects path silently does nothing.
- • Call this in BeginPlay (after Super::BeginPlay) or later — the subobject list is not processed until the component is fully registered and ready for replication. Calling it in the constructor has no effect.
Signature
ENGINE_API void AddReplicatedSubObject(UObject* SubObject, ELifetimeCondition NetCondition = COND_None) Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| SubObject | UObject* | The UObject subobject to register for replication. | — |
| NetCondition | ELifetimeCondition | Condition controlling which connections receive this subobject. | COND_None |
Return Type
void Example
Register a subobject in BeginPlay C++
void UMyComponent::BeginPlay()
{
Super::BeginPlay();
if (GetOwner()->HasAuthority())
{
MySubData = NewObject<UMySubData>(this);
AddReplicatedSubObject(MySubData);
}
} See Also
Tags
Version History
Introduced in: 5.1
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?