• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

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

Guest
May 23, 2013 May 23, 2013

Copy link to clipboard

Copied

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!

TOPICS
Expressions

Views

6.3K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , May 23, 2013 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

...

Votes

Translate

Translate
Community Expert ,
May 23, 2013 May 23, 2013

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Feb 25, 2016 Feb 25, 2016

Copy link to clipboard

Copied

Hi Dan,
Thanks for this, worked a dream.
However I hoped you could help with an addition to this. This currently works to move my y value in the opposite direction, but how can I add to this to move the x value in the same direction? I tried duplicating and changing y to x but to no effect.

Thanks,
Ryan

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 25, 2016 Feb 25, 2016

Copy link to clipboard

Copied

If you're talking about the first version, this should work:

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

p0 = p.valueAtTime(0);

d = p - p0;

value + [d[0],-d[1]]

Dan

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Feb 25, 2016 Feb 25, 2016

Copy link to clipboard

Copied

Sorry Dan my bad, I'm using the second version;

yRef = 640;

p = thisComp.layer("Left Face Null").transform.position;

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

I just need to add something to this which would also move x but in the same direction, not the opposite.

Thanks,
Ryan

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 25, 2016 Feb 25, 2016

Copy link to clipboard

Copied

Something like this, I guess, but you'll need to adjust the value of xRef:

yRef = 640;

xRef = 640;

p = thisComp.layer("Left Face Null").transform.position;

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

Dan

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 09, 2022 Jul 09, 2022

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 09, 2022 Jul 09, 2022

Copy link to clipboard

Copied

Something like this, probably:

xRef = 640;
p = thisComp.layer("Left Face Null").transform.position;
value - [p[0] - xRef,0]

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 10, 2022 Jul 10, 2022

Copy link to clipboard

Copied

Hi,

thanks for getting back! In my case, I have a circle moving from right to
left. I want another circle to start from the same position, except move in
the opposite direction (left to right). It's a bit difficult because I
spent quite a lot of time animating the circle moving right to left (using
easy ease) and simply want to replicate the velocity of that movement, just
right to left.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 10, 2022 Jul 10, 2022

Copy link to clipboard

Copied

Thanks for getting back! In my case, I have a circle moving from right to left. I want another circle to start from the same position, except moving the opposite direction (left to right). I spent quite a bit of time animating the circle moving right to left (easy ease mostly) and simply want to replicate the velocity of that movement, just right to left.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 10, 2022 Jul 10, 2022

Copy link to clipboard

Copied

Maybe like this:

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 10, 2022 Jul 10, 2022

Copy link to clipboard

Copied

Yes, that worked! Only issue is they both have the same starting position
now. Is there any way I can offset the "left to right" circle's starting
point?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 10, 2022 Jul 10, 2022

Copy link to clipboard

Copied

Like this maybe:

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 11, 2022 Jul 11, 2022

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 11, 2022 Jul 11, 2022

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 11, 2022 Jul 11, 2022

Copy link to clipboard

Copied

Working perfectly now - thank you!

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 11, 2022 Jul 11, 2022

Copy link to clipboard

Copied

delay = .2;

shortens the delay for me, as I would expect.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 11, 2022 Jul 11, 2022

Copy link to clipboard

Copied

Does this look correct?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 11, 2022 Jul 11, 2022

Copy link to clipboard

Copied

It does.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 11, 2022 Jul 11, 2022

Copy link to clipboard

Copied

I hada a stray keyframe messing things up. All good now. Deeply thankful for the help, Dan. All the best!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 12, 2022 Jul 12, 2022

Copy link to clipboard

Copied

My last rookie question - I should've done this before animating, but how would you go about centering these two shapes within the composition? The align tool just forces the both of them ontop of each other in the middle.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 12, 2022 Jul 12, 2022

Copy link to clipboard

Copied

LATEST

Hopefully, someone else will jump in, because I'm not sure what you're asking...

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines