Description
Marks this actor for destruction at the end of the current tick. Returns true if the actor will be destroyed (or is already pending kill), false if it is indestructible.
Caveats & Gotchas
- • Destruction is deferred to end-of-tick, not immediate. The actor pointer remains valid (non-null) until the GC runs. Always use IsValid() or the pending-kill check before dereferencing an actor you just called Destroy() on.
- • On a network client, Destroy() has no effect unless bNetForce is true or the server replicates the destroy. Actors are destroyed by the server and replicated down — clients do not own destruction authority.
Signature
ENGINE_API bool Destroy(bool bNetForce = false, bool bShouldModifyLevel = true); Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| bNetForce | bool | If true, forces destruction even during play on non-authority connections. Ignored outside of play. | false |
| bShouldModifyLevel | bool | If true, marks the level as modified before removing the actor. Set false for transient actors to avoid dirtying the level. | true |
Return Type
bool Example
Destroy an actor after a delay C++
// Called from a timer set in BeginPlay
void AMyActor::SelfDestruct()
{
Destroy();
// 'this' is still valid here but will be GC'd soon
} See Also
Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?