RealDocs

AActor::RemoveInstanceComponent

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

Description

Removes a component from the actor's InstanceComponents array. This is the counterpart to AddInstanceComponent and should be called before destroying a dynamically created component.

Caveats & Gotchas

  • Removing the component from the array does not destroy or unregister it. Call DestroyComponent() on the component separately if you want to fully remove it from the world.
  • If the component was not added via AddInstanceComponent (e.g. it is a native or Blueprint-created component), this call has no effect and does not log a warning.

Signature

ENGINE_API void RemoveInstanceComponent(UActorComponent* Component)

Parameters

Name Type Description Default
Component UActorComponent* The component to remove from the instance components array.

Return Type

void

Example

Remove and destroy a previously added instance component C++
if (MyDynamicLight)
{
    RemoveInstanceComponent(MyDynamicLight);
    MyDynamicLight->DestroyComponent();
    MyDynamicLight = 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.