The Wiggle Expression: Creating Movement in After Effects
In After Effects, use the wiggle expression to create random movement by modifying numbers, not keyframes.
Sometimes, our animation lacks character or feels a little lifeless. What would fix the issue is a slight bit of movement. The problem is, it’s tedious to manually set the keyframes for a continuous line of small adjustments, as you need to alter the properties every few frames and with no real consistency to keep the movement organic.
To work around this tedious task, follow the tutorial below to learn how to use the wiggle expression to remove the tedious nature of this incremental movement.
What Does the Wiggle Expression Do?
Now, unlike a script, which tells the application to do something, an expression will inform the individual property to do something. For example, this script tells the application (the application being After Effects) to position the anchor point of this layer to the center, the right, or the top.
With that covered, what about in the case of the wiggle expression? With a wiggle, we’re instructing the property, whether the scale, opacity, or position, to wiggle within the set parameters.
This is a lot faster than tediously animating the media item back and forth, or continually lowering the opacity or scale.
As noted in the examples above, although the wiggle expression is usually applied to an object’s position, there are numerous applications for the wiggle expression. If you’re emulating the light flicker from a candle using a solid color and adjusting its opacity, the wiggle expression is perfect for replicating the sporadic nature of a flickering flame.
How to Add a Wiggle Expression in After Effects
To show how a wiggle expression is added, I’ve created an end card that we’re going to pretend appears at the end of a recycling commercial. In the composition, we have a 3D camera moving upward with a visible parallax between the foreground and the mountains. We have the clouds moving in the background, and then a 3D push in. It looks quite nice. But this “YES!” to recycling is slightly boring. I think a wiggle to the position would be the perfect expression to give it more life.
To do this, we’re going to select the YES layer and hit P to open the Position Transform properties.
Hit Alt (PC) or Option (Mac) and click on the stopwatch to create the expression. The text turns red, telling you there’s an expression applied.
Type wiggle, open bracket, then the first number (which is the frequency of the movement), so 2 would be two movements per second, comma, then 50 (which is the amplitude of the movement), and close bracket. So, this expression reads that it’s going to wiggle 50 pixels on the x & y-axis twice a second.
So, let me break that down. The first number is how many times a second, the second is the amount of pixel movement.
If you want to modify the wiggle, change the numbers. If we had done this with keyframes, every time the client wanted changes, we’d have to change the keyframes. Not fun!
And, this can be done on several properties. We could wiggle the opacity and, instead of the amount of pixel movement, it’ll be the level of transparency—the same for scale and so on.
How to Keyframe a Wiggle Expression
While the wiggle, for the most part, is uncontrollable as its movement will repeat the motion until otherwise instructed, we can add some personalized wiggle movement with keyframes.
To do this, you want to open the property with the wiggle expression (in our case, the position), right-click, and select Convert Expression to Keyframes.
Now the expression is laid out as a series of keyframes, allowing you to adjust the position for specific areas and allowing you to stop and start the expression as you see fit.
However, stopping and starting an expression like this isn’t an elegant way of doing so. Let’s look at a more refined process that allows you to adjust the speed at which the wiggle operates.
How to Stop an Expression and Change an Expression’s Speed
A common technique is to add an expression control to a null layer. This means we’ll be operating the parameters through the null layer and not the layer the expression is on. While this seems convoluted, it’s more efficient when working with multiple expressions that you need synced to a single host.
Now, in our pretend example, we’re going to say that the client wants the area of movement to increase over the few seconds the “Yes!” is on screen, so we need to gradually increase the amplitude.
To do this, we need to first add a null object. Then apply the effect Sliders Control to the null. This can be found in the Expressions Controls category.
Select the wiggle control layer in the timeline, and type E to reveal the Slider Control effect. Click the triangle for Slider Control to see the stopwatch.
Go to the wiggle text expression and select just the 5. With the 5 selected, click on the pick whip and drag the pick whip to the Slider stopwatch.
The Slider is now controlling how much movement there is for the expression, or in better terms, the wiggle’s amplitude. Click the stopwatch to create a keyframe at the beginning, then move the playhead further in time and change the amount for the Slider to increase the wiggle.
Using a null object in this manner allows you to specify where the wiggle is to start and also by how much.
Wiggling One Dimension
What if you want to wiggle just the x or y position? This expression is a little more complicated, but you don’t have to write it. Copy the code below and keep it handy for the next time you need to wiggle one axis.
Wiggle only in x (horizontal): org=value; temp=wiggle (5,50); [temp,org];
Wiggle only in y (vertical): org=value; temp=wiggle (5,50); [org,temp];
Copy this text into your After Effects project and you’re done!
For more on After Effects, check out the articles below
- How to Create 3D Shapes with Newton 3’s 2D Physic Simulator
- How to Animate Individual Letters in Adobe After Effects
- After Effects: Presets vs Plugins vs Scripts vs Expressions vs Templates
- How to Write If/Else Expressions in After Effects
- 10 Practical Tips for Creating Sci-Fi HUDs in After Effects
Cover background image via Man As Thep.