Best way to do random spawn?
UtopianGames
Member Posts: 5,692
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.
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
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.
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