Getting a reference to a child actor

Hi there,

I’m new to UE4 and struggling to get a reference to a child actor.

In the attached image, I’m trying to fetch a reference to the “Actor” object from within the “Cloner” (with the intention of spawning new instances).

In the BeginPlay method of the Cloner class, Children.Num() returns 0, though I would expect it to be 1 in this case?
Children has a type of TArray< AActor* >, which looks like what I’m after… other than it being empty.

I also tried the RootComponent but couldn’t see any methods that return an AActor*. (I was thinking maybe it’s similar to how transforms are linked in Unity, with a GameObject attached to each).

I feel like I’m missing something obvious (and / or haven’t found the relevant docs)?

Any pointers in the right direction would be much appreciated.

Thanks

46926-world.jpg

Calling GetOwner() on a child component seems to do it:

AActor* childActor = RootComponent->GetChildComponent(0)->GetOwner();

To iterate over the children use RootComponent->GetChildrenComponents() and call GetOwner() on each component.

There might be a neater way, but it works for now.