Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Problem with linking correct layer.pos to pos/scale of above layer

  • Problem with linking correct layer.pos to pos/scale of above layer

    Posted by Jeremiah Batholomis on August 19, 2016 at 4:23 pm

    Hi,

    i wrote an expression to link the (center)position of layer 2 to the center of layer 1. Depending on position and scale of layer 1. That works pretty good as long as the anchorpoint of layer 1 is a negative value – f.e. on the top/left corner.

    What do i have to write to get this script working, independently from the position of the anchor point of layer 1?

    Thx!!

    Btw. Take a look at the AE-File attached!!
    10440_automaticposmask.aep.zip

    // --- Maskenebene

    a = thisComp.layer(index-1);

    //--- Y ----

    h = a.height;
    sh = a.transform.scale[1];
    aph = a.anchorPoint[1];
    aph2 = (h/2) - (aph*-1);

    maskh = (h*sh/100);
    masky = (a.transform.position[1]) - aph2;

    thisy = masky + (maskh/2);

    //--- X ----

    w = a.width;
    sw = a.transform.scale[0];
    apw = a.anchorPoint[0];
    apw2 = (w/2) - (apw*-1);

    maskw = (w*sw/100);
    maskx = (a.transform.position[0]) - apw2;

    thisx = (maskx + (maskw/2)) + effect("Slider X")("Slider");

    [thisx, thisy]

    Jeremiah Batholomis replied 10 years ago 2 Members · 5 Replies
  • 5 Replies
  • Dan Ebberts

    August 19, 2016 at 5:17 pm

    Like this maybe:

    a = thisComp.layer(index – 1);
    p1 = a.toComp([a.width,a.height]/2);
    p2 = toComp([width,height]/2);
    value – (p2 – p1)

    Dan

  • Jeremiah Batholomis

    August 20, 2016 at 9:48 am

    Thx for the Replay, but it too does only work if the Anchor Point is from zero to negativ.
    As soon as the AP-Value is positiv it stops working.

    Cheers

  • Dan Ebberts

    August 20, 2016 at 8:53 pm

    I must not understand what you’re trying to do, because for me, the expression will track the center of layer 1 no matter where its anchor point is.

    Dan

  • Jeremiah Batholomis

    August 22, 2016 at 7:57 am

    Mmmh … did you use Scale on layer 1? Because that is when it brakes the solution for me.
    Can u upload a AE-Example? Maybe i do something else wrong.

    Thx a lot anyway!!

  • Jeremiah Batholomis

    August 22, 2016 at 10:03 am

    Hey Dan, i have to correct my previous post. You are 100% right. It works pretty fine and in just 4 lines! Amazing!

    The problem was, that we use the (awesome) Motion-Plugin from Mt. Mograph and if you animate scale plus position and then reposition the AP with his plugin, theeeeen (i don’t know why, but) it turn into motion from hell 😉

    Thx for your help mate!

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