3 Separate Random Timers Fire at Same Time

ellfireellfire Member Posts: 187
edited April 2012 in Working with GS (Mac)
Hello, Gang. I currently have three actors that enter into a scene based on random timers in each of them. If they are "destroyed" or pass off screen on the other side, they recycle back to their original positions.

A strange behavior that I am noticing is that, sometimes, their random timers become synced causing 2 to come on screen at the same time. I tried to alleviate this by alternating their timers (Ex. Actor one every random(30,60) seconds enters. Actor Two every (35,65) seconds enters, etc.)

Does anyone have a method to get the random number generation to use different seeds so that they don't sync up? I'd prefer not to use a table. Thanks.

Best Answer

  • GreenHavenGamesGreenHavenGames Posts: 62
    Accepted Answer
    Use T-shirt booths random number without repeating method. No tables.



    This will allow the numbers to be checked against each other and randomize until they are different.

    Should work.



Answers

  • ellfireellfire Member Posts: 187
    Thanks @GreenHavenGames I use this method elsewhere in my game. It works well if the timer is one actor, but these are three different timers in three different actors. They launch a move behavior, not changing a global attribute that acts as a trigger. I don't mind if actor one flies every 30secs. (what tb's method would help stop). I just don't want actor one and two to fly at 30secs together.

    What I am looking for is some way to alter the random number generating algorithm to use a different seed number for its calculations. With this change, the random numbers would have a much lesser chance of syncing up.
  • GreenHavenGamesGreenHavenGames Member Posts: 62
    Then have them check against a global variable. Do this same concept at the global level instead of actor level.
  • ellfireellfire Member Posts: 187
    Actually, I ended up fixing them with the most non sophisticated way possible. I made one expression random(15,45), the 2nd actor's expression (random(15,45))+1, and the 3rd actor (random(15,45))+2. Works like a charm in this particular instance.
  • GreenHavenGamesGreenHavenGames Member Posts: 62
    That's a very clean solution! Good job.
Sign In or Register to comment.