Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Keeping an Object between two nulls?

  • Kevin Camp

    November 1, 2008 at 12:21 am

    something like this for the position of the layer should work:

    p1 = thisComp.layer(“Null 1”).position;
    p2 = thisComp.layer(“Null 2”).position;
    div(add(p1, p2),2)

    it should work for 2d or 3d positions.. not sure what would happen if one null was 2d and the other 3d…

    Kevin Camp
    Senior Designer
    KCPQ, KMYQ & KRCW

  • Pete Burges

    June 28, 2023 at 11:23 pm

    I hate to resurrect a dead thread but this was the most relevant…

    The expression used here works great as long as the layers you’re positioning between have keyframes on them. But what if they themselves are parented, or driven by expressions? In that case you need a way to track the anchor points….and that’s where I am stumped.
    …Or, I was. As I was typing my attempted script here I realised what was wrong with it and came up with the following, which worked!

    targetA = thisComp.layer(“targetA”);

    targetB = thisComp.layer(“targetB”);

    A = targetA.toComp(targetA.anchorPoint);
    B = targetB.toComp(targetB.anchorPoint);

    (A+B)/2

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