본문 바로가기
After Effects(English ver)

Using the Wiggle Expression in After Effects

by hfgraphic 2024. 6. 19.
반응형

The wiggle expression in After Effects is a highly useful feature that can add random movement to an object's properties (e.g., position, rotation, opacity, etc.). By using this expression, you can easily apply a natural shaking effect without manually setting keyframes.

 

The wiggle expression can be applied to any animatable value. Here, we'll use it on Position by Alt + Clicking the stopwatch and writing the wiggle command.

 

The basic syntax of the wiggle expression is as follows.

wiggle(frequency, amplitude)
 

 

  • frequency: This represents the number of shakes per second. The higher this value, the more frequently the object shakes.
  • amplitude: This represents the magnitude of the shake. The higher this value, the larger the object's movements.

You can observe how the object changes based on these two values.

 

The wiggle expression in After Effects is fundamentally composed of two parameters (frequency, amplitude), but it can be more finely controlled with additional parameters. The extended syntax of the wiggle expression is as follows:

wiggle(frequency, amplitude, octaves, amp_mult, time)

 

The meaning of each parameter is as follows:

  1. frequency:
    • Specifies the number of shakes per second.
    • Example: wiggle(2, 30) means 2 shakes per second.
  2. amplitude:
    • Specifies the magnitude of the shake.
    • Example: wiggle(2, 30) means a shake with a magnitude of 30 pixels.
  3. octaves:
    • Specifies the number of layers of noise. Higher values add more complex and detailed shakes.
    • Example: wiggle(2, 30, 3) adds three layers of noise.
  4. amp_mult:
    • Specifies the rate at which the amplitude decreases for each octave. Values typically range between 0 and 1.
    • Example: wiggle(2, 30, 3, 0.5) means the amplitude is halved with each octave.
  5. time:
    • Specifies the time at which the wiggle starts. By default, it uses the current time.

You can observe the changes in the object's behavior based on these parameters.

 

 

If the last parameter is not specified, time is used by default. The time parameter provides the variation over time. If you set it to 1, the value is fixed at the 1-second mark. If you set it to 5, the value is fixed at the 5-second mark. In this example, since the wiggle is applied to the Position value, the value will be fixed at the specified second.

 

The wiggle expression can also be used in more complex ways. For instance, you can apply different wiggle values to each axis in 3D space, as shown below.

xWiggle = wiggle(5, 50)[0];
yWiggle = wiggle(3, 30)[1];
zWiggle = wiggle(1, 10)[2];
[xWiggle, yWiggle, zWiggle]

 

In this case, you can set separate frequencies and amplitudes for each axis (x, y, z).

Additionally, the wiggle expression can be combined with other expressions to create more complex animations. For example, to make the wiggle operate only within a specific timeframe, you can use the time variable.

if (time < 5) {
    wiggle(2, 20)
} else {
    value
}

 

This code applies the wiggle expression up to 5 seconds, after which it retains the original value.

반응형