RealDocs

AActor::ClearInstanceComponents

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

Description

Clears the InstanceComponents array, optionally destroying every component in it. Pass true to fully remove them from the world; pass false to only remove tracking without destroying.

Caveats & Gotchas

  • • Passing bDestroyComponents=false leaves components alive in the world but no longer tracked by this actor — they will not be cleaned up when the actor is destroyed, which can cause dangling components.
  • • This does not affect native or BlueprintCreatedComponents. Only components previously registered via AddInstanceComponent are cleared.

Signature

ENGINE_API void ClearInstanceComponents(bool bDestroyComponents)

Parameters

Name Type Description Default
bDestroyComponents bool If true, calls DestroyComponent() on each component before clearing the array. —

Return Type

void

Example

Destroy all instance components on actor reset C++
// Fully remove all dynamically added components
ClearInstanceComponents(true);

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.