FORUMS: list search recent posts

Relative movement

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Pontus Danielsson
Relative movement
on Feb 14, 2013 at 7:39:25 am

Forgive me if I don't use the correct terms, but I'll try to explain my problem. I have layer "A" positioned in the middle of the composition. Layer "B" is also located in the center of the composition but offset in z-space. When I move layer A in the x-axis, I want layer B to follow, but with an extra movement. For example, if I animate layer A 100px to the right, I want layer B to move 150px to the right from the center. And if I move layer A 100px to the left of the center I want layer B to move 150px to the left.

So if layer A was animated from -100 px from composition center to 100px from center, layer B would move a total of 300 px and layer A 200 px.

Any idea what expression to use?

Thanks!

/Pontus


Return to posts index

Kevin Camp
Re: Relative movement
on Feb 14, 2013 at 9:14:29 pm

i think this does what you want:

target = thisComp.layer("A");
x = 1.5*(target.position[0]-thisComp.width/2)+thisComp.width/2;
[x,value[1],value[2]]


Kevin Camp
Senior Designer
KCPQ, KMYQ & KRCW


Return to posts index

Kevin Camp
Re: Relative movement
on Feb 14, 2013 at 9:23:22 pm

actually, that only works if the layer A is moving relative to the center of the comp.... let me think about this for a bit more...

Kevin Camp
Senior Designer
KCPQ, KMYQ & KRCW


Return to posts index


Kevin Camp
Re: Relative movement
on Feb 14, 2013 at 9:55:20 pm

if you can use a null (or other layer) as a parent to both layers A and B, and you make layer A's average position relative to the parent (so it's x position ranges from say -100 to 100, or -200 to 200), then this simple expression would work:

target = thisComp.layer("A");
x = 1.5 * target.position[0];
[x,value[1],value[2]]


essentially, you're using the parent to zero the position of both layers to make the math easy.

Kevin Camp
Senior Designer
KCPQ, KMYQ & KRCW


Return to posts index

Pontus Danielsson
Re: Relative movement
on Feb 15, 2013 at 8:00:20 am

Works like a charm!
Many thanks!

/Pontus


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2018 CreativeCOW.net All Rights Reserved
[TOP]