Skip to main content
May 23, 2013
Answered

Noob Question: Move a layer in the opposite direction of a different animated layer

  • May 23, 2013
  • 1 reply
  • 8580 views

So say that I have an icon that I animate on the Y-axis +40px, but instead of trying to hand key the other layer each time, is there an expression I can write to have the other layer move in the opposite Y direction the same amount of units (ex: -40px)?

Thanks!

Correct answer Dan Ebberts

You have to define what the y movement is relative to. For example, if you want one layer to mirror another layer's y movement since the first frame, you could do it like this:

p = thisComp.layer("leader").transform.position;

value + [0,p.valueAtTime(0)[1] - p[1]]

If you want to mirror it around a particular reference y value, it would be like this:

yRef = 540;

p = thisComp.layer("leader").transform.position;

value + [0,yRef - p[1]]

There are other variations/interpretations--it depends on what you're after exactly.

Dan

1 reply

Dan Ebberts
Community Expert
Dan EbbertsCommunity ExpertCorrect answer
Community Expert
May 23, 2013

You have to define what the y movement is relative to. For example, if you want one layer to mirror another layer's y movement since the first frame, you could do it like this:

p = thisComp.layer("leader").transform.position;

value + [0,p.valueAtTime(0)[1] - p[1]]

If you want to mirror it around a particular reference y value, it would be like this:

yRef = 540;

p = thisComp.layer("leader").transform.position;

value + [0,yRef - p[1]]

There are other variations/interpretations--it depends on what you're after exactly.

Dan

Participating Frequently
July 9, 2022

Hey! I know this is many years down the line, but how would you go about mirroring just the x value here?

Participating Frequently
July 11, 2022

Like this maybe:

p = thisComp.layer("right to left circle").transform.position;
x = (p[0] - p.key(1).value[0]);
value - [x,0]

Perfect, thank you!

How would you go about reversing the exact motion on the same object a few moments later. For example, the circle enters the frame from right to left with a certain velocity - how do I replicate the exact same velocity on the same object, as the circle exits frame from left to right