RealDocs

AActor::SetAutoDestroyWhenFinished

function Engine Blueprint Since 4.8
#include "GameFramework/Actor.h"
Access: public Specifiers: UFUNCTIONBlueprintSetter

Description

Sets whether this actor should automatically destroy itself when all its components are done and no timers or timelines remain active.

Caveats & Gotchas

  • For most custom actor subclasses, setting this to true has no effect without engine-side support for the 'finished' state — engine types like Particle System actors and audio actors use it; generic AActor subclasses do not unless they call Destroy() themselves.
  • This is a BlueprintSetter so it can be called from Blueprint event graphs on a per-instance basis, but the default is set in the constructor via the UPROPERTY default and cannot be changed in the CDO from Blueprint.

Signature

ENGINE_API void SetAutoDestroyWhenFinished(bool bVal);

Parameters

Name Type Description Default
bVal bool True to enable auto-destruction when the actor finishes.

Return Type

void

Example

Spawn a one-shot audio actor that cleans itself up C++
AAmbientSound* Sound = GetWorld()->SpawnActor<AAmbientSound>(SoundClass);
if (Sound)
{
    Sound->SetAutoDestroyWhenFinished(true);
    Sound->AudioComponent->Play();
}

Version History

Introduced in: 4.8

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.