RealDocs

AActor::GetParentComponent

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

Description

Returns the UChildActorComponent that created this actor, or nullptr if this actor was not spawned by a child actor component. Useful for distinguishing a child actor from an independently spawned one.

Caveats & Gotchas

  • Returns nullptr for actors spawned via UWorld::SpawnActor or SpawnActorDeferred — only child actors created by a UChildActorComponent will return a valid pointer.
  • Do not confuse with GetAttachParentActor(), which walks the scene attachment hierarchy. GetParentComponent() specifically queries the ChildActorComponent ownership relationship, not spatial attachment.
  • The returned component belongs to the parent actor's component hierarchy, so accessing it from a different thread is not safe without locks.

Signature

ENGINE_API UChildActorComponent* GetParentComponent() const

Return Type

UChildActorComponent*

Example

Check if this actor is a child actor C++
void AMyActor::BeginPlay()
{
	Super::BeginPlay();
	if (UChildActorComponent* ParentComp = GetParentComponent())
	{
		UE_LOG(LogTemp, Log, TEXT("Spawned by ChildActorComponent on %s"), *ParentComp->GetOwner()->GetName());
	}
}

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.