AActor::GetAllChildActors
#include "GameFramework/Actor.h"
Access: public
Specifiers: UFUNCTIONBlueprintCallableENGINE_API
Description
Fills an array with all actors spawned by `UChildActorComponent` instances on this actor. Optionally recurses into nested child actors.
Caveats & Gotchas
- • This function populates the output array with actors spawned by `UChildActorComponent` specifically — it does **not** return actors from the `Children` array (actors that were attached via `AttachToActor`). These are two different concepts.
- • With `bIncludeDescendants = true`, the recursion can be expensive for deep hierarchies. If you only need to iterate once per frame, cache the result rather than calling this in Tick.
Signature
ENGINE_API void GetAllChildActors(TArray<AActor*>& ChildActors, bool bIncludeDescendants = true) const; Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| ChildActors | TArray<AActor*>& | Output array filled with all child actor instances. | — |
| bIncludeDescendants | bool | If true, recursively include children of children. If false, only direct children are returned. | true |
Return Type
void Example
Notify all child actors of an event C++
void AMyParentActor::AlertChildren()
{
TArray<AActor*> Children;
GetAllChildActors(Children, /*bIncludeDescendants=*/true);
for (AActor* Child : Children)
{
if (IAlertable* Alertable = Cast<IAlertable>(Child))
{
Alertable->OnAlert();
}
}
} See Also
Version History
Introduced in: 4.14
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?