random number does not work

Get help using Construct 2

Post » Sun Apr 21, 2013 8:51 am

Hi, I am trying to spawn object every random seconds but when i use:
System > every 3 + floor(random(1,4))

it's spawning object every same time. I wan't to generate number every command use.

Thanks for reply.
B
9
S
2
G
1
Posts: 21
Reputation: 992

Post » Sun Apr 21, 2013 12:24 pm

@notsu - I think that's probably the expected behaviour for that action. My guess is that the event gets scheduled on the first call, and then the actions are run every n seconds as determined by the first time it ran. I could be wrong about that, though

A possible solution, if you're comfortable using functions, would be to set up recursive function that does what you want:

function "doSomething" > create object here
                         wait(3 + floor(random(1,4)))
                         call function "doSomething"

You'd have to manually call the function once to get it started, and then it should just go off on its own randomly - though to be honest, I haven't tried it :P
B
9
S
3
G
4
Posts: 63
Reputation: 3,083

Post » Sun Apr 21, 2013 3:34 pm

thanks, now it works.
B
9
S
2
G
1
Posts: 21
Reputation: 992


Return to How do I....?

Who is online

Users browsing this forum: farfetchd83 and 18 guests