Mastering Popular After Effects Expressions
Expressions in After Effects can significantly boost your motion design workflow, allowing you to automate repetitive tasks and create complex animations with just a few lines of code. Below are some must-know expressions to level up your projects.

1. Wiggle Between Two Values
The wiggle expression introduces randomness to an object’s movement, but sometimes you need to control it within specific limits. This version of the wiggle expression constrains movement between minimum and maximum values.
Code Example:
javascript
Copy code
min = -10;
max = 50;
freq = 5;
amp = Math.abs(max-min)/2;
offset = (max+min)/2;
wiggle(freq, amp) + offset;
- 
- 
How to Use: Attach this expression to properties like position or scale, and define your min/max limits and wiggle frequency for controlled oscillation. 
2. Wiggle on One Dimension
When animating objects, you may want them to wiggle in only one direction (X or Y axis) rather than in random directions. This expression restricts the wiggle to a single dimension.
Code Example:
javascript
Copy code
frequency = 2;
amplitude = 10;
w = wiggle(frequency, amplitude);
[w[0], value[1]];
- 
- 
How to Use: Apply this expression to a layer’s position. To limit the motion to the X-axis, use [w[0], value[1]]. For Y-axis movement, change it to [value[0], w[1]]. 
3. Loop Path Keyframes
Animating shape layers or masks often involves looping paths, which After Effects’ default loop expressions don’t handle well. This expression creates a seamless loop for keyframes on a path property.
Code Example:
javascript
Copy code
if (numKeys >1 && time > key(numKeys).time) {
t1 = key(1).time;
t2 = key(numKeys).time;
span = t2 - t1;
delta = time - t2;
t = delta % span;
valueAtTime(t1 + t);
} else {
value;
}
- 
- 
How to Use: Apply this expression to a shape layer or mask's path property to repeat the animation smoothly without copying and pasting keyframes. 
4. Time Remapping for Looping Animation
This expression creates an infinite loop of an animation, useful for repeating sections like walking cycles or any looping motion.
Code Example:
javascript
Copy code
loopOut("cycle");
- 
- 
How to Use: Place this expression on time remap keyframes to make the animation cycle continuously. You can also experiment with variations like "pingpong" for back-and-forth motion. 
5. Bounce Expression
To give your animations a more dynamic, natural feel, the bounce expression simulates a bouncing effect when an object reaches its final position.
Code Example:
javascript
Copy code
amp = 20; 
freq = 3;
decay = 5;
t = time - key(1).time;
amp*Math.sin(freq*t*2*Math.PI)/Math.exp(decay*t);
- 
- 
How to Use: Attach this expression to the position or scale of a layer to add a springy, bouncing effect to any animation. 
6. Controlling Multiple Layers with Nulls
Use a null object to control multiple layers at once by linking their positions. This expression helps maintain relative positions even as the null object moves.
Code Example:
javascript
Copy code
thisComp.layer("Null 1").transform.position + [100, 0];
- 
- 
How to Use: Attach this to any layer’s position property to move it relative to a null object. You can modify the offset [100, 0] to adjust its relative position. 
7. Fade In/Out with Opacity
Control the fade-in and fade-out of layers using this simple expression that triggers opacity changes based on time.
Code Example:
javascript
Copy code
linear(time, inPoint, inPoint+1, 0, 100);
- 
- 
How to Use: Apply this to the opacity property. The linear function smoothly transitions opacity from 0 to 100 between keyframes, creating a professional fade effect. 
Conclusion
By incorporating these After Effects expressions into your workflow, you can automate various animations and enhance your projects with ease. Whether it's controlling random motion with the Wiggle Expression, looping animations with Time Remap, or adding bounce to transitions, expressions provide endless creative possibilities.
For more advanced effects, you can combine these expressions or modify them to suit your specific project needs!
#AfterEffects #MotionGraphics #Expressions #AETutorial #AnimationTips #AEExpressions #WiggleExpression #LoopAnimation #BounceEffect #CreativeWorkflow #VideoEditing #VisualEffects #AECommunity #MotionDesign