Tweaking a Dan Ebberts expression: How to resolve a shape's random motion to its initial position?
Hi there -
I'm new to AE and am working on learning expressions by looking at existing expressions and tweaking them to understand how they operate.
I've been playing with one of Dan Ebberts's expressions to randomize motion of a shape in a comp and am wondering if there is a way to make the shape's "end position" at the conclusion of the timeline resolve to the shape's initial position (to create a seamless loop).
Any suggestions or tips on resources that might address this would be very welcome. Thank you!
Here is the expression of Dan's I've been working with:
moveMin = .3; //minimum move time
moveMax = .5; //maximum move time
pauseMin = .2; // minimum pause time
pauseMax = .5; // maximum pause time
minVal = [0*thisComp.width, 0*thisComp.height];
maxVal = [1*thisComp.width, 1*thisComp.height];
seedRandom(index,true); // set pre-run for endT
endT = - random(moveMax);
j = 0;
k = 0;
while ( time >= endT){
j += 1;
seedRandom(j,true);
startT = endT;
if (j%2){
endT += random(moveMin,moveMax);
k++;
}else{
endT += random(pauseMin,pauseMax);
}
}
if (j%2){
seedRandom(k,true);
endVal = random(minVal,maxVal);
seedRandom(k-1,true);
startVal = random(minVal,maxVal);
ease(time,startT,endT,startVal,endVal)
}else{
seedRandom(k,true);
random(minVal,maxVal)
}
