How to get a list of all children/attached actors?

I’m currently struggling with what appears to be a simple problem. I’m trying to find a list of all children of a given actor. This is what I’m currently doing:

     TArray< AActor* > tempChildActors;
      AActor* owner = GetOwner();
      owner->GetAllChildActors( tempChildActors, true );
    
      uint32 count = tempChildActors.Num();

However, the count is still 0. I’m wondering if I’m making some incorrect assumptions. My current setup is that I have a component on a parent actor. In this component, I’m calling the above code to retrieve the parent’s child actors. Here is a picture of the child actors parented.

113034-childobjects.png

I feel like I might be missing something very simple here, but I just can’t seem to figure it out.

1 Like

Hi , i see it is a bit late , but i am writing to help newcomers;
you have to use GetAttachedActors() for these ,
childactor is component actor of an actor.
You may want to read this post too:

1 Like

All you need is to call AActor::GetAttachedActors.

See the doc: AActor::GetAttachedActors | Unreal Engine Documentation

E.g

TArray<AActor*> AttachedActors; 
GetAttachedActors(AttachedActors); 
for (auto* Attached : AttachedActors)
{    
   Attached->Destroy();
}
2 Likes

This is empty at runtime.