Announcement

Collapse
No announcement yet.

How to iterate through all meshes attached to DefaultSceneRoot?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    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
    How to iterate properly? Thanks!

    Click image for larger version  Name:	getChildrenComponents.jpg Views:	0 Size:	233.1 KB ID:	1711397
    Attached Files
    Last edited by Apollo1444; 01-21-2020, 11:58 PM.

    #2
    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.
    Last edited by Droprint; 01-21-2020, 11:34 AM.

    Comment


      #3
      Try this:

      Click image for larger version

Name:	a1.png
Views:	130
Size:	170.9 KB
ID:	1711407
      "I have harnessed the shadows that stride from world to world to sow death and madness."

      Comment


        #4
        Originally posted by EvilCleric View Post
        Try this:

        Click image for larger version  Name:	a1.png Views:	13 Size:	170.9 KB ID:	1711407
        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)

        Click image for larger version

Name:	attachedToSceneComponents.jpg
Views:	86
Size:	232.0 KB
ID:	1711596
        Last edited by Apollo1444; 01-22-2020, 12:03 AM.

        Comment


          #5
          Originally posted by Apollo1444 View Post

          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)

          Click image for larger version  Name:	attachedToSceneComponents.jpg Views:	0 Size:	232.0 KB ID:	1711596
          You can use the "Get Children Components" node for that purpose.

          Click image for larger version  Name:	childcomp.jpg Views:	0 Size:	394.9 KB ID:	1711609

          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.
          Last edited by Stormrage256; 01-22-2020, 12:41 AM.
          Unreal Possibilities
          Grid Creation Systems | Tower Defense Starter Kit | Wave Spawning System [50% OFF]

          Comment


            #6
            Originally posted by Stormrage256 View Post

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

            Click image for larger version Name:	childcomp.jpg Views:	0 Size:	394.9 KB ID:	1711609

            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):
            Click image for larger version  Name:	0sceneAllChildren.jpg Views:	0 Size:	116.9 KB ID:	1711614

            Comment


              #7
              Originally posted by Apollo1444 View Post
              But "GetChildrenComponents" doesn't work for Scene, I'm getting just an empty array (instead of array of cubes):
              It's working for me:

              Click image for larger version

Name:	a2.png
Views:	95
Size:	16.3 KB
ID:	1711625


              Click image for larger version

Name:	a1.png
Views:	99
Size:	67.6 KB
ID:	1711624
              "I have harnessed the shadows that stride from world to world to sow death and madness."

              Comment


                #8
                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.
                Unreal Possibilities
                Grid Creation Systems | Tower Defense Starter Kit | Wave Spawning System [50% OFF]

                Comment


                  #9
                  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!

                  Comment

                  Working...
                  X