RealDocs

AActor::IsChildActor

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

Description

Returns true if this actor was spawned and is owned by a `UChildActorComponent`. Used to determine whether the actor's lifetime is managed by a parent component.

Caveats & Gotchas

  • Child actors are destroyed when their owning `UChildActorComponent` is destroyed or the parent actor is destroyed. Do not manually destroy a child actor with `Destroy()` unless you intend to invalidate the owning component.
  • Returns false for actors that were moved into a level's Child Actor Component slot but not yet spawned, and for actors spawned via `SpawnActor` even if they are later attached to a component.

Signature

ENGINE_API bool IsChildActor() const;

Return Type

bool

Example

Skip self-destruction logic for child actors C++
void AMyActor::OnHealthDepleted()
{
	if (IsChildActor())
	{
		// Let the parent manage our lifetime; just notify instead
		OnDefeated.Broadcast(this);
		return;
	}
	Destroy();
}

Version History

Introduced in: 4.14

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.