Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Possible to link anchor point to distance?

  • Possible to link anchor point to distance?

    Posted by Greg Howell on May 5, 2016 at 8:04 pm

    Hi Guys,

    It’s probably less confusing if I don’t try to explain exactly what I’m trying to build. Basically, I need an expression that will tell layer A to change its anchor point value between 0px (min) – 200px (max) depending on the pixel distance between layer B and C. Although the max distance between B and C wont be 100px, it will be more like 1920px or something.

    If anyone can help, it would be greatly appreciated.

    Thanks,

    Greg

    Kalleheikki Kannisto replied 10 years ago 2 Members · 5 Replies
  • 5 Replies
  • Kalleheikki Kannisto

    May 6, 2016 at 7:01 am

    This does what you describe. If you want the anchor point to change only in one direction (x or y), make the other return value 0.

    BC_dist = length(thisComp.layer("B").transform.position-thisComp.layer("A").transform.position);
    A_anchor = linear(BC_dist,0,1920,0,200);
    [A_anchor, A_anchor]

  • Greg Howell

    May 6, 2016 at 9:35 am

    Hi Kalle,

    Thanks for your response. Yes, I should of specified that it’s just the x axis i want to link the distance too. I cant get this to work. Is there any chance you could send over the project file so i could see it in action. that would be great.

    My email is: greghowell777@gmail.com

    thanks,

    Greg

  • Kalleheikki Kannisto

    May 6, 2016 at 4:05 pm

    Ok, sorry I had the layer names wrong, I used A and B to control C instead of B and C to control A.

    Here’s the project file, AECC14.

    10064_moveanchorpoint.aep.zip

  • Greg Howell

    May 7, 2016 at 9:53 am

    Thanks Kalle. Could you post the expression please. I cant open the file because I have an older version of AE (im using cs6)

    cheers

  • Kalleheikki Kannisto

    May 7, 2016 at 1:54 pm

    For layer “A” anchor point:

    BC_dist = length(thisComp.layer("B").transform.position-thisComp.layer("C").transform.position);
    A_anchor = linear(BC_dist,0,1920,0,200);
    [A_anchor, transform.anchorPoint[1]]

    Note that the layer names need to be “A” “B” and “C” respectively in order for this to work.

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