Random Doesn't Work
Until 9.5, expression 'random(min,max)' worked well for me. Now it doesn't seem to work at all. I had a timer that said every random(1,3) seconds it will do something, but it will always do it every 1 second. I then made a variable called self.random that starts at 3 and changes to a number from 1 to 3 every time the timer goes off. The timer goes off every self.random seconds. However, this time it will not change the variable and the timer will only go off every 3 seconds.
Is there a way to fix this?
Is there a way to fix this?
Comments
You have to set your self attribute and then a separate timer that says every 0 seconds change attribute to random(1,3) then use the attribute for your other timer duration be sure to check run to completion
Can someone please help me fix this issue?
When Attribute 'self.random' = 3
Spawn Actor
You'll have to play with the max number a bit to get the timing feeling right, but this will work, plus it removes a timer, which in the long run will help out your performance.
So even though what you want when you do something like this:
Timer
Every random(1,9)
.....
is for the Timer to fire at intervals like 3,4,7,5,2,1,4,4,7, etc..., what actually happens is that the Timer randomly picks a number, and then keeps using that number as the interval. So you get the Timer firing at intervals like 3,3,3,3,3,3,3,3,etc...
What you need to do is recreate, or "reseed" the Timer by wrapping it in a Rule.
Something like this:
First create a boolean attribute in the Actor called 'reseed'. Set this initially to true by checking the box.
The set up your Rule structure like this:
Rule
When All conditions are valid:
self.reseed is true
.....Change Attribute: self.reseed To: false
.....Timer
.....After random(3,6) run to completion (set 3 and 6 to whatever interval you want)
..........Spawn Actor: darkness
.....Timer
.....After 0.5 run to completion
..........Change Attribute: self.reseed To: true
Hope this helps!
Joe
p.s. also, in your above Rules, you have Run to Completion checked in a Timer that fires "every...". That is unnecessary.
This doesn't work. Now the object doesn't even spawn the darkness object.
timer every 1s:
chance = random(1,3)
rule chance == 1:
... do stuff
If GameSalad can't do something as simple as doing something from 1-3 seconds, I may as well stop using GS.
Uploaded with ImageShack.us
Thank you, it finally works!