Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Randomly Make 2 or More Shape Objects Light Up

MarcusOMarcusO Posts: 147Member
Can anybody help me out on how I can make 2 or more shape objects (square, triangle, etc) in a scene light up RANDOMLY rather than in sequence; as in one shape objects lights up after another in a particular order.
Thanks in advance.


  • dotsonj23dotsonj23 Posts: 316Member
    1. Create new Game Attribute (e.g., .randomlight)
    2. Create non-visible actor
    3. Add timer to Actor: Every __ seconds (however often you want something to light up)
    4. Add Constrain Attribute to behavior to Actor within Timer
    5. Constrain game.randomlight = rand(1, max) [note: for max put in the number for the total number of actors that can be light up (e.g., 10)
    6. Within each actor you want to light up add a boolean attribute (e.g. .lighton)
    7. Within each actor (I am using Actor 1 in this example) you want to light up add rule: When All--> game.randomlight = 1, change self.lighton to true.[Note if you want the light to turn off when another actor gets light up in the otherwise portion of the rule add When All --> game.randomlight does not = 1, change self.lighton to false; or it you want it to turn off after a certain period of time or another event just add that event to the otherwise rule and when it happens have it turn self.lighton to false]
    8. Within each actor key when the actor gets light up to whether its self.lighton is true or false.

    I think that should work. Also, if you don't want the same actor to light up twice in a row TShirtbooth has a demo showing how to not have random pick the same number twice in a row. I believe its on his website

    Hope it works for you.
  • MarcusOMarcusO Posts: 147Member
    Thanks for your reply.
    It was very useful. I've also checked out the recommended website. It too was very useful.
This discussion has been closed.