The more “natural” the animation is, the better it looks overall. This “naturalness” can be achieved in different ways. But creating all this with keys is very tedious. Expressions and scripts for After Effects will help us with this.
Standard Expression Bounce

amp = .025; //rebound amplitude
freq = 2; //rebound frequency
decay = 3; //attenuation power
n = 0;
if (numKeys > 0) {
n = nearestKey(time).index;
if (key(n).time > time) {
n--;
}
}
if (n == 0) {
t = 0;
} else {
t = time - key(n).time;
}
if (n > 0 && t < 1) {
v = velocityAtTime(key(n).time - thisComp.frameDuration / 10);
value + v * amp * Math.sin(freq * t * 2 * Math.PI) / Math.exp(decay * t);
} else {
value;
}
Expressions and scripts for After Effects Basket Bounce

e = .7; //высота отскока nMax = 3; //количество отскоков g = 5000; //гравитация n = 0; if (numKeys > 0){ n = nearestKey(time).index; if (key(n).time > time) n--; } if (n > 0){ t = time - key(n).time; v = -velocityAtTime(key(n).time - .001)*e; vl = length(v); if (value instanceof Array){ vu = (vl > 0) ? normalize(v) : [0,0,0]; }else{ vu = (v < 0) ? -1 : 1; } tCur = 0; segDur = 2*vl/g; tNext = segDur; nb = 1; // number of bounces while (tNext < t && nb <= nMax){ vl *= e; segDur *= e; tCur = tNext; tNext += segDur; nb++ } if(nb <= nMax){ delta = t - tCur; value + vu*delta*(vl - g*delta/2); }else{ value } }else value
A popular expression imitating the rebound of a basketball.

Vy0 = 500; //initial y velocity (pixels/second)
Vx0 = 100; // initial x velocity (pixels/second)
g = 2500; // gravity (pixels/second/second)
floor = 400;
e = .85; //elasticity
b = floor – position[1];
h = b + Vy0Vy0/(2g);
T = Vy0/g + Math.sqrt(2h/g); if ((time-inPoint) < T){ y = Vy0(time-inPoint) – g(time-inPoint)(time-inPoint)/2 + b;
}else{
Vy = -(Vy0 – g*T);
while (true){
Vy *= e;
t = T;
T += 2Vy/g; if ((time-inPoint) < T){ t = (time-inPoint) – t; y = Vyt – gtt/2;
break;
}else if (T – t < thisComp.frameDuration){
y = 0;
break;
}
}
}
[position[0] + Vx0*(time-inPoint), floor – y]
A simple expression that can be written as.

try {
freq = effect(“bounce – frequency”)(“Slider”); //oscillations per second
amplitude = effect(“bounce – amplitude”)(“Slider”);
decay = effect(“bounce – decay”)(“Slider”);
} catch(e) {
freq = 1;
amplitude = 200;
decay = 3;
}
posCos = Math.abs(Math.cos(freqtime2Math.PI)); y = amplitudeposCos/Math.exp(decay*time);
value – y
Script to automatically apply Bounce

A short script that writes a standard bounce expression to the selected property and adds three controllers (amplitude, frequency, attenuation) to the layer.
AutoFade in (apply to opacity) – Expressions and scripts for After Effects
//Autofade: Add to opacity
transition = 8; // transition time in frames
if (marker.numKeys<2){
tSecs = transition / ( 1 / thisComp.frameDuration); // convert to seconds
linear(time, inPoint, inPoint + tSecs, 0, 100) – linear(time, outPoint – tSecs, outPoint, 0, 100)
}else{
linear(time, inPoint, marker.key(1).time, 0, 100) – linear(time, marker.key(2).time, outPoint, 0, 100)
}
Expression for countdown timer in After Effects (apply to Source Text)
//Countdown Timer (apply to Source Text) t = Math.floor(time); s = 240 - t; minutes = Math.floor(s/60); seconds = s-(minutes*60); if(seconds < 10) { seconds = '0' + seconds; } minutes + ':' + seconds;
Time Remap Expressions for After Effects
//Apply to Time Remap pos = transform.position; delay = -1; //in seconds x = Math.pow(pos[0]-960,2); y = Math.pow(pos[1]-540,2); d = Math.sqrt(x+y); value + linear(d,0,1102,0,delay);
Expression in After Effects to rotate at a constant speed without keyframes
// Spin (rotate at a constant speed without keyframes) veloc = 360; //rotational velocity (degrees per second) r = rotation + (time - inPoint) *veloc; [r];
To move in a spiral (apply at position) Expressions for After Effects
//Moves things in a spiral (apply to position) center=[thisComp.width/2,thisComp.height/2]; rMax = 240; //maximum radius decay = 0.3; //decay freq = 6; //frequency aStart = 0; //start angle offset aRate = 220; //rotation rate offsetFactor = 1000; //smoothness r = rMax/Math.exp(time*decay); a = degreesToRadians(aStart + aRate*time); offset = (r/offsetFactor)*Math.sin(freq*time*Math.PI*2);center + [Math.cos(a),Math.sin(a)]*(r + offset);
Expressions for After Effects to move at a constant speed without keyframes
// Throw (move at a constant speed without keyframes) veloc = -10; //horizontal velocity (pixels per second) x = position[0] + (time - inPoint) *veloc; y = position[1]; [x,y];
Wiggle Expression in After Effects
wiggle(1,15)
Wiggle expressions of chaotic value change. This expression can be used to make your scene look more organic and natural.
The first number is the number of shifts per second, and the second number is the wiggle value.
Time Expression in After Effects
time*10
The Time expression is ideal for objects with infinite motion. For example, if you want an object to rotate indefinitely, you can simply add the word time as a rotation parameter and your object will rotate 1 degree for the duration of the composition. The time parameter also works with basic math equations, so if you want the layer to rotate 30 times faster, you can simply write time*30
loopOut Expression in After Effects for looping animation
loopOut()
Loop animation. The loopOut() expression requires keyframes. So if you have a layer that rotates in a circle for 1 second, you can add a loopOut() statement and the movement will repeat in a loop
seedRandom Expression (Expression) in After Effects for randomness (randomness)
seedRandom(5)
Math.round Expression in After Effects for randomness
Math.round()
Math.round() is an expression that rounds decimal numbers to the nearest whole number. It’s perfect for doing countdowns or numbers in source text. Just add your source expression to the parenthesis of the Math.round() expression in the source text expression field and all your numbers will be rounded
Expression (Expression) Snap Zoom In/Out в After Effects
Apply to text. Apply on the Scale parameter. This expression creates layer scaling at the beginning and end of the layer
//Snap zoom in and out: apply to scale snapScale = 300; //percent of scale to zoom trans = 4; // transition time in frames trans = trans * thisComp.frameDuration; inTrans = easeOut(time, inPoint, inPoint + trans, [snapScale,snapScale], [0,0]); outTrans = easeIn(time, outPoint, outPoint - trans, [0,0], [snapScale, snapScale]); value+ inTrans + outTrans
If you are using the Z axis then use this expression
zoom = 5000; //distance to zoom trans = 4; // transition time in frames trans = trans * thisComp.frameDuration; inTrans = easeIn(time, inPoint, inPoint + trans, [0,0,zoom], [0,0,0]); outTrans = easeOut(time, outPoint, outPoint - trans*2, [0,0,0], [0,0,zoom]); value+ inTrans - outTrans
Y Axis Jitter Expression in After Effects
// Y Axis Jitter probability = 8 ; //higher is less likely pos = 50; val = random(-probability-2, 1); m = clamp(val, 0, 1); y = wiggle(10, pos*m)-position; value + [0, y[1]]