RealDocs

AActor::GetAttachedActors

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

Description

Populates OutActors with all actors that are directly attached to any component on this actor via scene attachment. Pass bRecursivelyIncludeAttachedActors = true to collect the entire attachment subtree.

Caveats & Gotchas

  • Only returns actors attached via scene component attachment (AttachToActor / AttachToComponent). Actors spawned as child actors via UChildActorComponent are included here only if their root component is also attached.
  • bResetArray defaults to true — if you call this in a loop and intend to accumulate results across actors, pass false and manage the array yourself.
  • The recursive flag performs a depth-first traversal and can be expensive on deep attachment chains; cache the result rather than calling every frame.

Signature

ENGINE_API void GetAttachedActors(TArray<AActor*>& OutActors, bool bResetArray = true, bool bRecursivelyIncludeAttachedActors = false) const

Parameters

Name Type Description Default
OutActors TArray<AActor*>& Array that receives the list of attached actors.
bResetArray bool If true, clears OutActors before populating it. true
bRecursivelyIncludeAttachedActors bool If true, also includes actors attached to the directly-attached actors, and so on. false

Return Type

void

Example

Destroy all directly attached actors C++
TArray<AActor*> Attached;
GetAttachedActors(Attached);
for (AActor* Child : Attached)
{
	Child->Destroy();
}

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.