Skip to main content
Participant
January 6, 2020
Question

How to "mirror" motion

  • January 6, 2020
  • 1 reply
  • 609 views

How can I mirror motion. Leet's say we've got 2 doors of an elevator

________

|      ||      |  

|      ||      |

|___||___|

they open. Not linary, but in some kind of weird motion faster-slower-faster.

If I create the motion for the left door, how can I mirror it for the right door?

 

thank you

This topic has been closed for replies.

1 reply

Mylenium
Legend
January 6, 2020

Dipends on how the motion is actually created. if it's e.g. a 3D layer it could be as trivial as adding a minus in front of a pickwhip expression referencing the other layer, give or take additional corrections required to get the correct angle. Similar logic applies to pretty much everything - invert it/ multiply with -1 and/ or subtract value A from a full value on the otehr side to get B. Simple math.

 

Mylenium

Participant
January 6, 2020

Of cause, the way how it's created...

Simply keyframes in the Transform menue of the layer.

How can I turn it to the math expression?

Community Expert
January 6, 2020

Let's say you have two layers making up the doors. The layers are named Left Door and Right Door. Select both layers and press A to reveal the Anchor Point of both layers.

 

Animate the Anchor Point of "Right Door" to move it to the right.

Add an expression to the "Left Door" position property by Alt/Option-clicking on the Anchor Point stopwatch, type a = and then drag the pickwhip to the Anchor Point of the "Right Door" layer, type a semicolon, press Return, then type [- a[0], a[1]] and close the expression. Changing the Anchor Point of the right door will now change only the X value of the anchor point of the Left door but it will be in the opposite direction. The complete expression will look like this:

a = thisComp.layer("Right Door").transform.anchorPoint;
[- a[0], a[1]]

 If you wish to animate the Position of the layers instead of the Anchor Point the expression gets a lot more complicated requiring you to subtract half the comp width and height from the position and then performing the same kind of math. I won't bother with that expression. 

 

A third option would be to not add keyframes to either layer but instead, add an Expression Slider Control to the Left door and then set keyframes for the slider. The slider would be tied to the position property of both layers but it would add the value of the Slider to the Right Door's x value and subtract it from the left. If you applied the Expression Control Slider to the Left Door then the Position expressions for the doors would look like this:

// right door
opn = thisComp.layer("Right Door").effect("Slider Control")("Slider");
[value[0] + opn, value[1]]

// left door
opn = thisComp.layer("Right Door").effect("Slider Control")("Slider");
[value[0] - opn, value[1]]

 

You could use similar expressions for Rotation to make doors swing in opposite directions or scale. The trick to making it work easily is to subtract a value from the property in one layer and add it to the same property in another. All you have to remember is that Position, Anchor Point, and Scale are arrays, arrays are always enclosed in square brackets, and x is 0, y is 1 and z is 2.