Random question please help
azavega
Member Posts: 362
Can't find this post but I'm sure somebody ask this before...
Trying to spawn actors falling from the top down using random but I can't get a nice flow of actors...
They fall down almost on the same spot over and over...
Somebody have a better idea?
Trying to spawn actors falling from the top down using random but I can't get a nice flow of actors...
They fall down almost on the same spot over and over...
Somebody have a better idea?
Comments
So timer its set to every(random(1,5) spawn actor blue and another timer set to every(randon(2,6) spawn actor red...
-Josh
otherwise it will randomize it only once (when opening), and then use that same number over and over again.
did that make sense?
I know that you want a Timer with every(random(1,5) to spit out something like:
1,2,3,2,4,5,1,2,5,3,4,4,3 etc...
But it doesn't work like that.
The Timer will randomly pick the first number, but then it will use that number for the rest of the time that the Timer is active.
So it will spit out numbers like:
3,3,3,3,3,3,3, etc.
or 2,2,2,2,2,2,2, etc.
To make it work correctly, you need to destroy the Timer and recreate it each time.
Something like this will work:
Create a new Boolean attribute in the spawner Actor called 'reseed'. Set it initially to true (check the box).
Then a Rule is the spawner like this:
Rule
When all conditions are valid:
self.reseed = true
.....Change Attribute: self.reseed to: false
.....Timer After random(1,5)
..........[do something]
..........Timer After 0.1 seconds Run to completion
...............Change Attribute: self.reseed to: true
Hope this helps!
Joe
EDIT: Strobanik beat me to it!
Also, if you are making a jumping game like Doodle Jump, ToastKitten made a nice jumping game template with randomly appearing platforms.
Switch Between Clockwise and Counter-clockwise Rotation
Make a timer that every second, change the value of a self.Random attribute to random(1,10), then have a Rule that checks if that attribute is a certain value. If it is, for example, 1 then spawn a blue actor. If it is 2, then spawn a red one. You can increase the frequency of spawning by changing the upper random limit from 10 to, say, 5.