OK then. Let’s make it a little training exercise. First the code.
Instead of a text layer, you would create a null, name it “master”, add a slider to it, and add this expression to the slider:
setSize = 25;
t = Math.round(time);
setNo = Math.floor(t/setSize);
setIdx = t%setSize;
seed = Math.floor(setNo);
seedRandom(seed,true);
posArray = [];
for (var i = 0; i < 25; i++){
posArray[i] = i;
}
for (var i = 0; i <25; i++){
idx = Math.floor(random(i));
temp = posArray[idx];
posArray[idx] = posArray[i];
posArray[i] = temp;
}
posArray[setIdx]
As before, this layer needs to be at the bottom of your layer stack.
Then add this position expression to your grid layers:
holdTime = .75
setSize = 25;
setNumber = Math.floor(time/holdTime);
myTime = setNumber*setSize + index - 1;
posX= [130, 284, 438, 591, 745];
posY = [132, 294, 455, 617, 778];
myIdx = thisComp.layer("master").effect("Slider Control")("Slider").valueAtTime(myTime);
myXIdx = Math.floor(myIdx/5);
myYIdx = myIdx%5;
[posX[myXIdx],posY[myYIdx]]
If you can figure out how it works, I'd have to say that you've learned quite a bit about expressions.
Bonus points if you can answer these questions:
1. Why will this method fail if your comp is longer than 7 minutes and 12 seconds?
2. If your comp is longer than that, what could you do to make this method work?
🙂
Dan