[SOLVED] How do I select objects using this criteria?

  • Hi guys, I've been trying to do this selection for a while now but I can't quite get it to work.

    I'll summarise the issue I'm having:

    • 10 sprites in 'All Objects' family. (Can be a random amount but for now I'm using 10)
    • Family has instance variables of "Dead" and "Running".

    Let's say 5 of those objects have the 'Dead' flag set - I only want to trigger an action if ALL the remaining 5 objects have the 'Running' flag set.

    It seems so simple, but I just keep bashing my head against a brick wall. I'm running into issues trying to code it so would value some expert advise on this please!

    Thanks in advance!

    Zacros

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • One way could be to do this. Each is a seperate event.

    Global number numPicked=0

    Every tick -> set numPicked to 0

    Family: is dead -> add family.pickedcount to numPicked

    Family: is running -> add family.pickedcount to numPicked

    NumPicked=family.count -> trigger action

    Or you may be able to do this with two conditions in one event.

    System: pick family by comparison family.dead+family.running>0

    System: compare family.count=family.pickedcount

    ->trigger action

  • Mate, that's perfect!

    I used the second option - hadn't really looked at solving the problem in that way, so thank you!

    Cheers

    Zacros

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