Random Motion
These are the basic expressions for generating random motion. These expressions independently generate random values for position, scale, and rotation, 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.
This is the expression for position:
tMin = .25; //minimum segment duration
tMax = 1.0; //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(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)
Adjust tMin and tMax to set the range of times it will take to move from one position to the next.
This is the expression for rotation:
tMin = .25; //minimum segment duration
tMax = 1.0; //maximum segment duration
minVal = 0;
maxVal = 720;
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)
This is the expression for scale:
tMin = .25; //minimum segment duration
tMax = 1.0; //maximum segment duration
minVal = 75;
maxVal = 150;
end = 0;
j = 0;
while (time >= end){
j ++;
seedRandom(j,true);
start = end;
end += random(tMin,tMax);
}
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)