Expression Library

Random Position

Author: Dan Ebberts

Randomly repositions a layer within a specified value range at random time intervals.

Code Sample

Hover over the code and click the copy button.

				
					tMin = .25; //adjust to set the minimum time to move from one location to another
tMax = 1.0; //adjust to set the maximum time
minVal = [0.1*thisComp.width, 0.1*thisComp.height];
maxVal = [0.9*thisComp.width, 0.9*thisComp.height];

end = 0;
j = 0;
while (time >= end){
  j ++;
  seedRandom(j,true);
  start = end;
  end += random(tMin,tMax);
}
endVal =  random(minVal,maxVal);
seedRandom(j-1,true);
dummy = random(); //this is a throw-away value
startVal =  random(minVal,maxVal);
ease(time,start,end,startVal,endVal)