-
Random expression: force new number
I would like to create an expression that gives me a new value every frame, meaning it shouldn’t show the same value twice in a row. This turns out surprisingly difficult when you want to have a random number between 1 and 3 like me.
For example: I currently get an output per frame like this: 1,3,3,2,1,1,3,2
But I’d like to have something like this: 1,3,2,3,1,2,3,2,1I have tried various comparison loops, if and while statements and but just can’t figure out the root of the issue.
In case you’re interested in my current code:
holdTime = framesToTime(1)
seed = Math.floor(time/holdTime);
seedRandom(seed, true);
x = Math.floor(random(1,4));
val = effect(“Slider A”)(“Slider”); // Slider control which holds the number
valNow = val.valueAtTime(time); // Number at current time
valBefore = val.valueAtTime(time-(1/24)); Number of the frame before
//I assume there should follow some sort of comparison now
x;Thanks a bunch
Michael