Random Motion by Dan Ebberts
These are the basic expressions for generating random motion. These expressions independently generate random values for position, scale, rotation, and opacity and move to the new values at a random speed.
The expressions can easily be adapted for other properties and effects, 1D or 3D motion, etc.
segMin = .3; //minimum segment duration segMax = .7; //maximum segment duration 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(segMin,segMax); } 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) Adjust segMin and segMax to set the range of times it will take to move from one position to the next.
segMin = .3; //minimum segment duration segMax = .7; //maximum segment duration minVal = -720; maxVal = 720; end = 0; j = 0; while ( time >= end){ j ++; seedRandom(j,true); start = end; end += random(segMin,segMax); } 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)
This is the expression for scale:
segMin = .3; //minimum segment duration segMax = .7; //maximum segment duration minVal = 50; maxVal = 200; end = 0; j = 0; while ( time >= end){ j ++; seedRandom(j,true); start = end; end += random(segMin,segMax); } s = random(minVal,maxVal); endVal = [s,s]; seedRandom(j-1,true); dummy = random(); //this is a throw-away value s = random(minVal,maxVal); startVal = [s,s]; ease(time,start,end,startVal,endVal)
segMin = .3; //minimum segment duration segMax = .7; //maximum segment duration minVal = 10; maxVal = 100; end = 0; j = 0; while ( time >= end){ j ++; seedRandom(j,true); start = end; end += random(segMin,segMax); } 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)