RealDocs

AActor::RemoveReplicatedSubObject

function Engine Since 5.1
#include "GameFramework/Actor.h"
Access: public

Description

Unregisters a UObject from this actor's replicated sub-object list, stopping future property replication. Does not destroy the object on remote peers — use DestroyReplicatedSubObjectOnRemotePeers if immediate client cleanup is needed.

Caveats & Gotchas

  • Calling this does NOT immediately destroy the sub-object replica on connected clients. Existing client instances are left alive until they are garbage-collected on the client side or you explicitly call DestroyReplicatedSubObjectOnRemotePeers.
  • Must be called before destroying the sub-object on the server to avoid dangling pointer references in the registry.
  • If the sub-object was never registered (or was already removed), the call is silently ignored. Use IsReplicatedSubObjectRegistered to check first if needed.

Signature

ENGINE_API void RemoveReplicatedSubObject(UObject* SubObject)

Parameters

Name Type Description Default
SubObject UObject* The sub-object to unregister from the actor's replication list.

Return Type

void

Example

Remove a sub-object before destruction C++
void AMyActor::OnInventoryCleared()
{
    if (IsReplicatedSubObjectRegistered(InventoryData))
    {
        RemoveReplicatedSubObject(InventoryData);
    }
    InventoryData->MarkAsGarbage();
    InventoryData = nullptr;
}

Version History

Introduced in: 5.1

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.