1. A simple expression to make a wheel spin in relation to the horizontal position.

If you have a Null object called "wheel controller" to animate the X position, the expression on your wheel layer would look like this:

circ = (width*(scale[0]/100)) * 3.1416;
360/circ *thisComp.layer("wheel controller").transform.position[0];

Note: The wheel should be a child of "wheel controller"

2. Basic Wiggle that can be applied to the position, scale, opacity ....

the code is built as Wiggle(A,B)
A= Frequency(x times per secondes)
B= Amplitude in pixel

as here for example applied on the position
wiggle(5,25)

3. Inertial Bounce
can be put on the scale, position ... and creates this bounce as when a ball hit the ground

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){
v = velocityAtTime(key(n).time - thisComp.frameDuration/15);
amp = .05;
freq = 4;
decay = 8;
value + v*amp*Math.sin(freq*t*2*Math.PI)/Math.exp(decay*t);
}else{
value;
}

Watch Out for some reason, the enter (=go to next line) are replaced by ? sign that is not understood by AE, so be sure to delete the ? mark to have the expression working

otherwise here is the a version without enter

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){v = velocityAtTime(key(n).time - thisComp.frameDuration/15);amp = .05;freq = 4;decay = 8;value + v*amp*Math.sin(freq*t*2*Math.PI)/Math.exp(decay*t);}else{value;}

4. Add twice the effect "Slider Control", call one "freq" and the other "amount"

When you add the wiggle expressions, connect the amount to "amount" and the frequency to the other one:
wiggle(effect("freq")("Slider"), effect("amount")("Slider"))

Now you can keyframe the sliders and start and stop and manipulate the wiggle.

5. It is applied to the OPACITY of the layer. It picks a random number for the opacity value the layer only some of the time, based on whether another random number ("probability") is less than or equal to 1. You can change the likelyhood of a random opacity being selected by changing the value of "probability."

The rest of the time the opacity is set to the value of "opacity_normal" which is set to 100 by default.

This concept be easily adaptable to other times when you only want something to happen some of the time by using the if...else operators. For example - you could apply something similar to the position or rotation of a layer and it would hop around some of the time.
//applyTo: opacity
// HIGHER values for probability make a random opacity LESS likely.
// A value of 1 will always create a random opacity, a value of 2 will
// create a random opacity 50% of the time, value of 4 will be 25%, etc.

probability = 6;
// "opacity_normal" is the value set for opacity when the a random opacity is NOT chosen.
opacity_normal = 100;
x = random(probability);
if (x);

# After Effects Expressions Library

Coline Brun-Naujalis

A library of After Effects expressions to make animation easier. If you have any expression you would like to see in the channel, drop me a mail and I should do something about it.

#### Shout Box

Heads up: the shoutbox will be retiring soon. It’s tired of working, and can’t wait to relax. You can still send a message to the channel owner, though!

Channels are a simple, beautiful way to showcase and watch videos. Browse more Channels.