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?

Dan Ebberts
Community Expert
Community Expert
July 11, 2022

Working perfectly now - thank you!

For some reason, when I alter the daley = .2 it does not shorten the time before reverse?


delay = .2;

shortens the delay for me, as I would expect.