re: seedRandom(index,true)
by David Rodriguez
on
May 14, 2008 at 8:30:19 pm
I have used seedRandom(index,true); twice in this expression.
The first works exactly as I would expect it to.
The second seedRandom(index,true); applied to elasticity achieves undesirable results.
This bounce expression is applied to hundreds of ball graphics, instead of randomizing the elasticity across all of the balls it raises the elasticity from .89 to 1 from the left of the screen to the right.
Re: re: seedRandom(index,true) by Dan Ebberts on May 14, 2008 at 8:40:18 pm
When you reset the seed to a previous value (the layer's index in this case) the random sequence you get when call random() starts over. So in your case,
random(-400,400);
and
random(.89,1);
actually generate the same random number, scaled by the parameters inside the parens. So that means that elasticity will be proportional to the x velocity, which will give you exactly the results you are seeing.
What were you trying to accomplish be resetting the seed?
Re: re: seedRandom(index,true) by Dan Ebberts on May 14, 2008 at 9:13:41 pm
It will, but you don't need (or want) to reset the seed first. You should only need to use seedRandom() once in an expression unless you're doing something tricky and need to regenerate a random number from the past.