RealDocs

AActor::GetAttachParentActor

function Engine Blueprint Since 4.11
#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
Event BeginPlay Is Valid Input Object Input Object Is Valid Not Valid Print String In String Has attach parent! Has attach parent! Get Attach Parent Actor Target is Actor Return Value
Edit Blueprint graph Check if attached to a parent actor and print its existence
Drag node headers to move · Drag from an output pin to an input pin to connect · Scroll to zoom · Right-click for actions
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());
	}
}

Version History

Introduced in: 4.11

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.