How to iterate through all meshes attached to DefaultSceneRoot?

Hi guys!
I have bunch of cubes attached to my DefaultSceneRoot in actor class.
I need to apply impulse to all of them.

I expected “DefaultSceneRoot->GetChildrenComponents” to give me array of my attached cubes.
But it doesn’t work :frowning:
How to iterate properly? Thanks!

why do you print the index ? try to make a node on pin array element and search for cubeN

Put a debug breackpoint on for each loop and let’s see what is in your children array by put your mouse on it.

Try this:

THX man! It helped! May I also ask how to iterate through meshes attached to another StaticMesh or Scene component?
(“GetComponentsByClass” doesn’t work in such case)

You can use the “Get Children Components” node for that purpose.

By default, it will provide only components that are direct children of your component. If you want grand children components as well, tick the “Include All Descendants” option.

But “GetChildrenComponents” doesn’t work for Scene, I’m getting just an empty array (instead of array of cubes):

It’s working for me:

a2.png

a1.png

It should work regardless of the type of component. Try adding a small delay of like 0.1 seconds at the start of Event Begin Play. It could be possible that the components haven’t all been completely initialized yet.

@EvilCleric @Stormrage256 thanks guys, but for some reason it still doesn’t work for me (even with delay)
(looks like bug or something)

But I’ve found that there’s “GetComponentsByTag” node. I guess it’ll suit my purposes, I’ll pre-tag my cubes.
Thanks a lot for help!