First, I’m trying to make it so that things fall out of the sky at random locations, at random intervals. I have it set up perfectly, except that the Random sensor fires waaaaayyyyy too fast. Is there any way to slow it down?
Secondly, with the Edit Object/Add object actuator, is there any way to add an object randomly picked from a list?
1rst: to slow down your random generator you just change the tick rate (were is says f: 0), 50 is 1 second between ticks.
And for the add an object from a list you would have to add the add object actuators for all the objects in the list to each empty or whatever you are using to spawn them then use a script of some sort to decide which one to drop(I could be more specific if I knew how your game was programmed).
-gomer
I would suggest that you use the “.getRandomFloat()” python function to produce a range of random numbers, rather than the logic brick methods.
rand = int(GameLogic.getRandomFloat() * 3) + 1
# The "3" being the end number in the range and the "1" being the beginning.
# So in this case, "rand" can be either 1, 2, or 3 at every script pass.
You can use a timer property, to control the speed of any given spawn:
if own.time > 1:
if rand == 1:
#action
if rand == 2:
#action
if rand == 3:
#action
own.time = 0
Yes, use the same setup as I have above, replace “#action” with "act.setObject(“objname”).
I assume you know how to replace “#action” with the code that you need, like relocating the spawn empty, and activating the actuator itself in addition to what I have already listed.
Just for clarification: the 3 is not the end number, but the # of possible outcomes. So it will produce 1, 2, or 3, but if the 1 was a 3, then the range would be 3, 4, or 5.
Thanks for posting that code Social. I asked this because adjusting the tickrate did nothing, which is a tad frustrating since it really should. I’ll give this code a try. Thanks.