AActor::GetAttachParentActor
#include "GameFramework/Actor.h"
Access: public
Specifiers: UFUNCTIONBlueprintPure
Description
Walks up the scene attachment chain from RootComponent and returns the first actor it belongs to that is different from this actor. Returns nullptr if this actor is not attached to any component owned by a different actor.
Caveats & Gotchas
- • Traverses the scene component attachment hierarchy, not the ChildActorComponent ownership chain. Use GetParentActor() if you want the actor that spawned this one as a child actor.
- • Returns nullptr if the actor's root component is unattached or if the attachment chain only passes through components owned by the same actor (e.g. attached to one of its own components).
- • The returned actor may be destroyed before this call completes in rare async or streaming scenarios — check IsValid() on the result before dereferencing.
Signature
ENGINE_API AActor* GetAttachParentActor() const Return Type
AActor* Examples
Check if attached to a parent actor and print its existence
Blueprint
Find the actor this actor is spatially attached to C++
void AMyActor::BeginPlay()
{
Super::BeginPlay();
if (AActor* AttachParent = GetAttachParentActor())
{
UE_LOG(LogTemp, Log, TEXT("Attached to: %s"), *AttachParent->GetName());
}
} See Also
Tags
Version History
Introduced in: 4.11
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?