Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Relative movement

  • Posted by Pontus Danielsson on February 14, 2013 at 7:39 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

    Pontus Danielsson replied 13 years, 5 months ago 2 Members · 4 Replies
  • 4 Replies
  • Kevin Camp

    February 14, 2013 at 9:14 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

  • Kevin Camp

    February 14, 2013 at 9:23 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

  • Kevin Camp

    February 14, 2013 at 9:55 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

  • Pontus Danielsson

    February 15, 2013 at 8:00 am

    Works like a charm!
    Many thanks!

    /Pontus

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy