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

0 favourites
  • 3 posts
From the Asset Store
Add emotion, innocence, joy and cuteness to your video game with these 15 songs and 9 SFX
  • 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.

  • 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 
    
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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)