How to make a more flexible wiggle in After Effects

Written on 30 June 2016, 01:58am under Quick Tips

The typical wiggle expression in After Effects is this:

wiggle(frequency, amplitude)

So if you would like your position to move on a scale of 20 pixels every half second you would use this expression on the position property:

wiggle(.5, 20)

How to wiggle x, y and z separately

The wiggle function returns an array or numbers. If you are applying it on a 3D layer, it returns an array of three numbers ([x, y, z]) and if you are applying it on a 2D layer it returns an array of two numbers ([x, y]). If you want to just wiggle one of the axis of a 2D layer you can simply do this:

var wiggle = wiggle(.5, 20);

[wiggle[0], value[1]];

Here, only our value x will have the wiggle. The only difference with a 3D layer is that it would need a third value.

If you would like instead to have x wiggled normally, but y and z to have a bigger wiggle you could do:

var low_wiggle = wiggle(.5, 20);
var high_wiggle = wiggle(.5, 50);

[low_wiggle[0], high_wiggle[1], high_wiggle[2]];

How to keyframe the wiggle values

You often might want to keyframe a wiggled value. This can easily be resolved by creating a null layer, typically named Controller, to which you would apply two Slider Control effects. One namedFrequencythe other one Amplitude. You can name them however you like, but I think these names are the most obvious. Next, on your layer’s position property, you would add this expression:

wiggle(thisComp.layer("Controller").effect("Frequency")("Slider"), thisComp.layer("Controller").effect("Amplitude")("Slider"));

This way, you would be able to keyframe one or both of those sliders in order to increase or decrease the wiggle effect.

How to sync multiple wiggles

You can sync multiple wiggles by using the seedRandom() function. By default After Effects attributes a different seed value to each wiggle. The seedRandom() function forces the wiggle (or any other function using random numbers) to use the seed your are providing.

seedRandom(1, true);

wiggle(thisComp.layer("Controller").effect("Frequency")("Slider"), thisComp.layer("Controller").effect("Amplitude")("Slider"));

The first parameter (1) is the seed number that will be used to generate the random number. It can be whatever you like. The second parameter is the timeless parameter. If you don’t set it to true the random number will change on every frame and this will probably result in things you do not want. If you use the expression above on many layers, all of their wiggles will be coordinated.

How to wiggle the wiggle

The good thing about using a controller, is you can apply a wiggle to the amplitude too. To do this, you will need to add another slider to your controller. Name it maybe Wiggle value and set its base amount to the the number you want to start from, say 50 for example, and then apply the same kind of expression:

wiggle(effect("Frequency")("Slider"), effect("Amplitude")("Slider"))

Now, you can apply to your layer’s position this expression:

value + thisComp.layer("Controller").effect("Wiggle value")("Slider")

Since value represents what your property already holds as its base value. It will be supplemented with Wiggle value.

Now, since Wiggle value is a Slider Control, it only has one dimension. If you use it with a property that has 2 dimension, say scale for example, both first and second values will be the same. If you want them to be different, instead of using a Slider Control for your Wiggle value use a Point Control for 2 dimensions, and 3D Point Control for 3 dimensions such as position for 3D layers.

And that’s about it. If you want to learn more about the wiggle expression you can read about it here:


Other popular articles