Skip to main content
May 23, 2013
解決済み

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

  • May 23, 2013
  • 返信数 1.
  • 8580 ビュー

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!

解決に役立った回答 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

Dan Ebberts
Community Expert
Dan EbbertsCommunity Expert解決!
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

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

Something like this probably:

delay = .5; // pause before reverse
if (numKeys > 1 && time > (key(numKeys).time + delay)){
   valueAtTime(key(numKeys).time - (time - (key(numKeys).time + delay)));
}else
  value