Best way to do random spawn?

UtopianGamesUtopianGames Member Posts: 5,692
edited November -1 in Working with GS (Mac)
Hi Guys,

Trying to make one actor choose and spawn between 5 actors by using the following.

I have a game.choose integer set to 1 and in my spawn actor i have

Every 5 seconds change attribute game.choose to random 1,5

Then i made 5 rules, if game.choose=1 spawn actor 1 and so on.

This works but does not spawn an actor every 5 seconds, it misses 1 or 2 in a row sometimes.

Wondering if this is the best way to do it?

Regards,

Darren.

Comments

  • design219design219 Member Posts: 2,273
    You might try delaying you spawn rule with another timer: After 1 second spawn. It could be the numer generation and the spawn muck with each other.

    Also, are you sure it's not working? Could it be that it is just spawning the same actor? If you want to make sure you get a different actor spawned each time, you will need another attribute and more rules.
  • mercyparkmercypark Member Posts: 20
    YES I HAVE BEEN LOOKING FOR THE ANSWER TO THIS FOREVER!!!! What is the other attribute and more rules... I am trying to spawn randomly 16 actors but everytime it spawns the same actor twice it doesn't spawn an actor at all.
  • JGary321JGary321 Member Posts: 1,246
    Change Attribute self.random # to Random (1,5)

    If 1 Spawn Unit 1
    Change self.random # to 6

    If 2 Spawn Unit 2
    Change self.random # to 6

    The reason for this is if it selects the same # 2 times in a row, it will not spawn again. So you set it to a number that is not in the random sequence.

    JGary
  • TraXsiv2TraXsiv2 Member Posts: 29
    I also am trying to do this. I have everything set up correctly accept for the "random part" what exactly do i setup to make it select a random number between 1 and 6. thank you
Sign In or Register to comment.