Does anybody know a quick random number generator?
Hey All.
I am trying to make an animation play at random times, like this:
Timer
Every random(3,6)
[play animation]
What I was hoping for was to get a sequence like: 4,3,3,6,5,4,6,5,etc...
What happens is that it initially picks a random number between 3 and 6, then keeps on using it.
So I get a sequence like this: 4,4,4,4,4,4,4,etc...
If I reload the game, I might get a sequence like this: 3,3,3,3,3,3,3,etc...
I know this has been talked about before.
Just checking if somebody has an easy solution.
It's not for a complicated spawning setup, just a simple background animation.
So it has to run without any user input.
Is there a way to force it to get a new seed every time?
Perhaps by using something like game.Time?
Any help is appreciated.
Thanks!
Joe
I am trying to make an animation play at random times, like this:
Timer
Every random(3,6)
[play animation]
What I was hoping for was to get a sequence like: 4,3,3,6,5,4,6,5,etc...
What happens is that it initially picks a random number between 3 and 6, then keeps on using it.
So I get a sequence like this: 4,4,4,4,4,4,4,etc...
If I reload the game, I might get a sequence like this: 3,3,3,3,3,3,3,etc...
I know this has been talked about before.
Just checking if somebody has an easy solution.
It's not for a complicated spawning setup, just a simple background animation.
So it has to run without any user input.
Is there a way to force it to get a new seed every time?
Perhaps by using something like game.Time?
Any help is appreciated.
Thanks!
Joe
Comments
Timer
Change attribute game.animation random (1,6)
Then rule
if game.animation =1
animate 1
if game.animation = 2
animate 2
etc etc
Problem i can see with that is that each animation change would be done probably at set intervals. i.e if you said timer random (3,6) it'll pick the random number and keep changing on that
@beefy: it is just one animation, like having a character blink.
@tempo: It shouldn't reset the scene.
@rob2: yeah, spawning, or resetting the game/Scene will reseed the random number, but I was hoping to not have to do that.
@tshirt: that would sort of work, but it wouldn't be random, and I would have two timers running...
Basically, I want something like this: Every 5-10 seconds, have my character blink. Right now they always blink at 6 seconds, or always at 8 seconds, etc...
I was just trying to vary it a little.
I tried this with Danger Cats and Stunt Squirrels. The characters do blink, but it is always at the same interval. The interval changes when you change levels.
Right now I am trying to do a similar thing with a lightning bolt flashing.
No big deal, just wanted to know if anybody had an easy trick.
Every 8 seconds change attribute game.animation (random x,y)
if animation = x
after 2 seconds
animation
if animation = y
after 5 seconds
animation
etc etc
thanks for the ideas!
it is the BUG?how to solve?
thanks
after 1 second,
every random(2,8) seconds.
spawn bird....
(just tried making a test project to upload, but the random is not being random....maybe it does not work in my game and I'd never noticed...hmm)
posted a trimmed quake builder project here, can't seem to get it to load, may be my internet connection...
http://gamesalad.com/game/play/56757
OR....
how about trying interpolate instead of a timer. To vary a game attribute, incase that works instead of a timer...
Create an integer attribute and call it something like Random Blink Animation.
In your actor that you want to animate add a timer and make it EVERY 2 seconds.
Inside the timer drag in a change attribute and select the "Random Blink Animation" attribute that you created and change the attribute to random(0,5).
Then, OUTSIDE of that timer, just make a new rule that says if the attribute is > 2
Then just put in an Animate behavior and drop your blinking images, and there you have it, a time based randomly animated blink! These numbers create a pretty convincing timing between blinks, but you can change them around to get something that fits your project.
Hope this helps, and happy creating!
You do know that this topic is 8 months old and since then everybody knows, how to make a number random, don't you?
Firemaple is one of the best GS game creators, so I was wondering his question, until I looked at the date of the topic :-D
I don't know how many times I've searched for a resolution to a problem in other programs and found forum posts from years ago that were never finished. I'm just doing my part to cap off issues that I run into so that no one else has to have the same problem.
Thanks