RealDocs

AActor::Destroy

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

Description

Requests that the actor be destroyed. Triggers the destruction sequence: EndPlay → UnregisterComponents → GC. In networked games, only the server should call Destroy(); the destruction is replicated to clients automatically.

Signature

bool Destroy(bool bNetForce = false, bool bShouldModifyLevel = true)

Parameters

Name Type Description Default
bNetForce bool If true, forces destruction even in networked contexts. false
bShouldModifyLevel bool If true, the level will be marked dirty after the actor is removed. true

Return Type

bool

Caveats & Gotchas

  • Destroy() in network games should only be called on the server (check `HasAuthority()`).
  • The actor is not immediately removed from the world. It becomes "pending kill" and is removed at the end of the frame.
  • After calling Destroy(), `IsValid(Actor)` returns false.

Example

Destroying an actor safely C++
if (IsValid(MyActor))
{
    if (HasAuthority()) // Server only in multiplayer
    {
        MyActor->Destroy();
    }
}

Version History

Introduced in: 1.0

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.