RealDocs

AActor::RemoveOwnedComponent

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

Description

Removes a component from the actor's OwnedComponents set. Called automatically by UActorComponent during unregistration; rarely needs to be called directly.

Caveats & Gotchas

  • Removing a component from OwnedComponents does not destroy it or detach it from the scene. Call `Component->DestroyComponent()` to fully tear down a dynamically added component.
  • Calling RemoveOwnedComponent on a component that is still registered will leave the component in an inconsistent state where it is active in the world but invisible to GetComponents. Always unregister first.
  • Like AddOwnedComponent, this is an internal bookkeeping function. Prefer `DestroyComponent()` for normal component removal workflows.

Signature

void RemoveOwnedComponent(UActorComponent* Component)

Parameters

Name Type Description Default
Component UActorComponent* The component to remove from this actor's OwnedComponents set.

Return Type

void

Example

Proper component removal via DestroyComponent C++
// Correct way to remove a dynamic component — DestroyComponent calls RemoveOwnedComponent internally
if (MyDynamicComp)
{
    MyDynamicComp->DestroyComponent();
    MyDynamicComp = nullptr;
}

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.