Skip to main content
Participating Frequently
April 27, 2023
Answered

Wobbling image back and forth.

  • April 27, 2023
  • 1 reply
  • 889 views

Hey guys, i'm looking for some help in animating an image of the inside of a train carriage so it slowly wobbles from left to right in a random manner. It would actually be back-and-forth via the z axis from the POV of the camera, which is facing the side window. 

This topic has been closed for replies.
Correct answer Ando0o0

Wiggle is also based on the index value of the layer. It's good practice to set a "seedRandom(##)" before the wiggle expression. This way if you like a certain wiggle pattern, it will not change when you move the layer up or down, or when you add new layers. 

1 reply

ShiveringCactus
Community Expert
Community Expert
April 28, 2023

The simplest approach here would be to use a wiggle expression.  If you hold down ALT and click on the train layer's position stopwatch and expression area opens and you can type:

wiggle(1,30)

This would move the whole layer once per second by up to 30 pixels from the original value.  Increasing the 1 to 10, would see 10 changes per second etc...

You say you only want the movement on the Z position, so assuming you have a 3D layer set up, we can actually wiggle in one axis only with a slightly different expression:

var rocking = wiggle(1,30);
X = value[0];
Y = value[1];
Z = rocking[2];
[X,Y,Z]

 

Value is the original value, rocking is the wiggle amount.  Wiggle is smart enough to know if it is wobbling in 1, 2 or 3 dimensions, so we use the [2] to only look at the Z axis.

Ando0o0
Ando0o0Correct answer
Inspiring
April 28, 2023

Wiggle is also based on the index value of the layer. It's good practice to set a "seedRandom(##)" before the wiggle expression. This way if you like a certain wiggle pattern, it will not change when you move the layer up or down, or when you add new layers.