How do I check that all Boolean Instance Variables in a Family are 'True'

  • I'm trying to set up a turn system, so I'm basically checking to see if all enemies have moved. Once an enemy moves a tile it sets it's Family Boolean Instance Variable to true.

    Once all Family Boolean Instance Variables are true, I'd like to revert control to the player. So what's the best method for triggering something once all Family Boolean Instance Variables are true.

    Thank you :)

  • You could use family.count for the number of enemies in the level. You can then do a separate family.pickedcount with a condition that the variable is true and compare the 2 numbers.

  • Thank you plinkie,

    Could you show me how this works in terms of the events themselves? I think I understand but I'm not sure how to implement it.

    Thank you so much!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 2 global variables.

    On start of layout (or some other trigger), set global variable 1 to family.count

    Every tick, with condition (C) family.boolean=true, set global variable 2 to family.pickedcount

    Compare 2 variables, if global variable 1 = global variable 2, end turn

    You should see global var 1 as the total family members, you can set this once if the number of enemies doesn't change or at random intervals if the number of enemies will change. Global var 2 should be increasing as the boolean becomes true for the instances. Run it in debug to make sure it's acting correctly.

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