AActor::GetParentActor
#include "GameFramework/Actor.h"
Access: public
Specifiers: UFUNCTIONBlueprintCallable
Description
Returns the actor that owns the UChildActorComponent which created this actor, or nullptr if this actor was not spawned as a child actor. This is equivalent to calling GetParentComponent()->GetOwner().
Caveats & Gotchas
- • Returns nullptr for actors that were not created by a UChildActorComponent — do not assume a non-null result unless IsChildActor() is true.
- • This traverses the ChildActorComponent ownership chain, not the scene attachment hierarchy. An actor can be spatially attached to another actor (via AttachToActor) without GetParentActor() returning anything.
- • If a child actor is subsequently detached from its spawning component at runtime, the result may still be valid since the component owns the actor until it is destroyed.
Signature
ENGINE_API AActor* GetParentActor() const Return Type
AActor* Example
Access the owning actor of a child actor C++
void AMyChildActor::BeginPlay()
{
Super::BeginPlay();
if (AActor* Parent = GetParentActor())
{
// Notify the parent that this child has started
Parent->Tags.AddUnique(FName("HasActiveChild"));
}
} Tags
Version History
Introduced in: 4.14
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?