How do I assign a random boolean to a set of objects?

0 favourites
  • 3 posts
From the Asset Store
Easily generate many levels from a set of pre-built scenes (Construct 3 template)
  • I can a set of Spot objects which have a boolean instance variable of isActive.

    [attachment=0:304x8zq5][/attachment:304x8zq5]

    Once a second I want random spots to toggle this state (as opposed to above, where all are toggles every second).

    I've seen the randomnumber(0,1) method, but I can I convert the number into true or false.?

  • There are two options as I see it.

    1. Change isActive to a number rather than a boolean and just use 0 and 1 to represent false and true, respectively.

    2. Add another condition to event 7 along these lines:

    System: Compare two values: choose(0, 1) = 1[/code:22aacxjv]
    Which will choose randomly from 0 and 1, if the value is 1, then the condition is true and your Spot's isActive boolean will toggle.
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Cheers Linkman,

    I did a little bit before seeing your post. What I have now is making the isActive random, now however, gradually all the spots get isActive set to true. It takes about ten seconds.

    [attachment=0:4zekdmgz][/attachment:4zekdmgz]

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