Pick all FamilyA that belong to FamilyB? *Solved*

0 favourites
  • 3 posts
From the Asset Store
Pick Up Items Sound effects for your game, Take them for a ride right now and you will worry no more.
  • C2 doesn't do sub-families (yet), so I'm using an approach where I assign the effective parent family to every effective child family.

    If I'm working with an instance of the ChildFamily, how can I pick it as the ParentFamily? For example, I'd like to do the equivalent of this:

    ChildFamily collides with Bouncer:
    + Pick ChildFamily as ParentFamily:
         -> Set ParentFamily.VelocityX to -50
    

    EDIT: SOLVED

    I think I found a solution and I'd like to share it here for reference. Whenever you'd like to pick as another family within a condition, run a ForEach loop for the ChildFamily. As a sub-event in the loop, Pick the ParentFamily by the UID that matches the ChildFamily. Since UID is a completely unique identifier for the object, this will work perfectly. Here's the above example working with my solution:

    ChildFamily collides with Bouncer:
    + For each ChildFamily
      + ParentFamily: Pick Instance with UID ChildFamily.UID
        -> Set ParentFamily.VelocityX to -50
    

    I hope that in the future C2 will natively support sub-families. It will make C2 that much more awesome.

  • You could also call a function with the ChildFamily.UID that collided, and in this function pick the parent by UID using the UID you put in param.

    In this case, it's the same (as you would need a for each anyway to call the function on all children that collided) but in general it could be better, for example if you have multiple sources of velocity lost in your game. You would then just have to call the same function.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Ah, good idea. I will probably use a function in my case because I'm going to have a lot going on. Thanks!

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