How do I pick children of a family object that are inside the same family object?

From the Asset Store
112 High-Quality destruction sounds for videogames
  • I need to create a loop for object in family "objects" that have children "objects"

    In code something like this:

    for each objects
    repeat objects.ChildCount
    objects pick child objects instance loopindex
    do stuff
    

    As a workaround I've created a second family, which purpose is only to host the objects from the first family so I can reference them, but I'm looking for slicker solution that doesn't require a feeder.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Creating another family is the easiest solution.

    You can make your code shorter:

    For each Objects2
    Objects2 Pick Own children Objects
     For each Objects 
     	Set variable children to (children=""?"":children & ",") & objects.object_id 
    
  • Thanks for the input! The solution did seem hacky, but I couldn't think of anything else that would work outside of writing a script. I guess I'll just use a host family to do the picking.

    Unfortunately, I can't really use objects2 to loop since the snippet is a part of a larger function, but as a standalone it does look better.

    I did, however, like your approach to the comma solution so I'm yoinking that! Very neat indeed.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)