Wiggle on One Dimension Only (X, Y, or Z)

Adds wiggle to just one axis (X, Y, or Z), leaving the others untouched. Great for controlled random movement.

Author:
Denis Stefanides
Category:
Wiggle

Wiggle on X only

// Wiggle only on X axis
freq = 3; // wiggles per second
amp = 50; // wiggle amount in pixels

w = wiggle(freq, amp);  
[w[0], value[1]] // wiggle X, keep Y unchanged
jsx

Wiggle on Y only

// Wiggle only on Y axis
freq = 3; // wiggles per second
amp = 50; // wiggle amount in pixels

w = wiggle(freq, amp);  
[value[0], w[1]] // keep X steady, wiggle Y
jsx

Wiggle on Z only (3D layers only!)

// Wiggle only on Z axis
freq = 3; // wiggles per second
amp = 50; // wiggle amount in pixels

w = wiggle(freq, amp);  
[value[0], value[1], w[2]] // X and Y stay fixed, wiggle Z
jsx

Where to Apply

You can apply this to any Position, Anchor Point, or any property that has multiple dimensions—even 3D effects or camera positions. Just make sure the layer is 3D if you’re using the Z option.


How It Works

This one's super handy when you want randomness but only in one direction. Normally, wiggle(freq, amp) affects all dimensions at once (X and Y, or X, Y, Z), which can get messy if you only want a subtle camera shake horizontally or just a vertical bounce.

So what this does is:

  • Runs wiggle() like usual.

  • Stores the result in a variable w, which contains the new [x, y] (or [x, y, z]) values.

  • Then we rebuild the original value, keeping the dimensions we don’t want to wiggle untouched.

That way, you get the wiggle you want exactly where you want it—no more, no less.

Frequently asked questions

How do I use the expression on this page?

Just copy the full expression code from the top of this page. Then Alt-click (or Option-click on Mac) the stopwatch on the property you want to animate. Paste the code into the editor and that's it. If you’re not sure which property to use, check the "Where to Apply" section above.

The expression isn’t working. What should I check?

First, make sure your project is using the JavaScript engine (go to File > Project Settings > Expressions). Also double-check for missing characters, and see if the code requires parenting a layer. If so, there will be a comment in the code explaining what needs to be connected.

I’m not sure what the expression does. Where can I learn more?

Take a look at the "How It Works" section on this page. It explains each part of the expression in plain language so you can understand how everything works together.

Can I customize how the expression behaves?

Yes, absolutely. Most expressions include easy-to-edit variables near the top and comments that guide you on what to change. You can also link sliders or checkboxes using Expression Controls if you want more control in the timeline.

Can I apply this to other properties too?

Yes, you can use it on any property with a stopwatch. That includes Position, Scale, Opacity, and also effect settings like Blur or Tint.

Will it work in comps with different frame rates or sizes?

In most cases, yes. These expressions are designed to adapt to your comp’s resolution and frame rate. If anything specific needs adjusting, it’ll be noted in the code or in the "How It Works" section.

Related Expressions

Explore more expressions in this category