I’m trying to write some logic that will loop through all of the actors that are attached to a target object. The objects are attached to the parent using AttachActorToActor. The idea is to loop over the actors and find the ones that match a certain type and then call an event on them.
I’ve done a bunch of searching and I’ve only been able to turn up one potential solution, but it only would work in C++. AActor has a variable Children, which contains a list of all actors that have their Owner set to this actor. This variable is not exposed to Blueprint, however, so I’m unable to use it without changing the engine code.
Does anyone know if there’s a way to do this? Thanks.
If you are searching for the target object then you can get the children components on there. But if you are looking for all the child components you can then get their owner, then just add them all into an array and cast to each of the children.
This. This right here is what has stopped my progress long ago.
For some reason, retrieving the child components of something did not return valid results. Perhaps I was casting incorrectly (very likely).
Like using a child component to the owner to get a different child component. Example, a health component looking for a death component on their NPC owner.
Using the child actor component only works for finding actors that were attached at build time. I’m attaching my actor using AttachActorToActor, which attaches the actor directly, rather than creating a component. This is why I’m stuck.