Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Forums Adobe After Effects Referencing null movement with relative position offset

  • Referencing null movement with relative position offset

  • Mark Warner

    April 3, 2014 at 11:58 am

    Hello. I’m sure this is a real simple expression but it has me stumped.

    I have a comp with numerous items scattered all over the place. I’ve applied some positional movement to a “master” null. I want the numerous items to follow what the null is doing but while they are in their current position, i.e. movement is relative to their current position.

    Ultimately, I want to add a time delay to each item or I’d just parent everything to the null! The time delay is the easy bit, it’s getting the expression/maths for the offset between my master null and the items I’m struggling with.

    Any help would be much appreciated!

  • Walter Soyka

    April 3, 2014 at 2:44 pm

    The offset between two positions is simply their difference: one minus the other.

    offset = thisComp.layer("Null 2").transform.position - thisComp.layer("Null 1").transform.position;

    If you want to get fancy, you can use world space, which will work even if the nulls are parented differently:

    offset = thisComp.layer("Null 2").toWorld(thisComp.layer("Null 2").transform.anchorPoint) - thisComp.layer("Null 1").toWorld(thisComp.layer("Null 1").transform.anchorPoint);

    Walter Soyka
    Principal & Designer at Keen Live
    Motion Graphics, Widescreen Events, Presentation Design, and Consulting
    RenderBreak Blog – What I’m thinking when my workstation’s thinking
    Creative Cow Forum Host: Live & Stage Events

  • Mark Warner

    April 4, 2014 at 9:49 am

    Hi Wayne

    thanks for you post. It’s nearly there but there’s something not quite right. When your posted script is executed my object jumps away from it’s current location. I can move it back into position manually (theres some weird mirroring of movement going on when I do this (i.e., I move the item left but it moves right)).

    I’d rather the objects stay where they are and follow my “master” movement that way. I’m guessing there’s some additional constant that needs adding to do this but can’t figure it out.

  • Matt Davis

    April 7, 2014 at 6:16 pm

    This might be the poor man’s answer (I use expressions but I don’t claim any large amount of understanding of them) but what if you made copies of your Master Null, all with the same motion then parent one object to one Null and just move the Null’s keyframes to offset the time as desired?

    If you have a lot of objects this might be tedious, and maybe there’s another reason you want to do it using expressions. But if it’s not quite working for you with expressions and you have the patience, it’d work.

  • Walter Soyka

    April 7, 2014 at 6:50 pm

    [Mark Warner] “thanks for you post. It’s nearly there but there’s something not quite right. When your posted script is executed my object jumps away from it’s current location. I can move it back into position manually (theres some weird mirroring of movement going on when I do this (i.e., I move the item left but it moves right)).”

    Sorry, I was just telling you how to calculate the offset, not how to fit it into your own expression.

    To do that, you’d have to take the expression above and add ‘value’:

    offset = thisComp.layer("Null 2").toWorld(thisComp.layer("Null 2").transform.anchorPoint) - thisComp.layer("Null 1").toWorld(thisComp.layer("Null 1").transform.anchorPoint);
    offset + value;

    This doesn’t take into account your valueAtTime() stuff, which you’ll have to add yourself.

    Walter Soyka
    Principal & Designer at Keen Live
    Motion Graphics, Widescreen Events, Presentation Design, and Consulting
    RenderBreak Blog – What I’m thinking when my workstation’s thinking
    Creative Cow Forum Host: Live & Stage Events

  • Mark Warner

    April 8, 2014 at 9:25 am

    Thanks again for everyones help. Just couldn’t get it to work so re-scanned the internet with different terminology, found this, works great!

    myParent = thisComp.layer("master");
    myProp = myParent.transform.position;
    value + (myProp.value - myProp.valueAtTime(0))

    You have to add keyframes in order to see this work. If you move you “master” null around on frame 0 nothing will happen – it’s the keyframes further down the timeline where the magic happens!

  • Pete Burges

    January 30, 2023 at 10:39 pm

    I’ve been using the myParent script for years, but I haven’t yet figured out how to adapt it to track an anchor point in comp space rather than the keyed position. I find that tracking an anchor is more flexible because you can track a layer that is parented to something else and doesn’t need keyframes.
    So I tried this:

    target = thisComp.layer(“Target”);
    myProp = target.toComp(target.anchorPoint);
    value + (myProp.value – myProp.valueAtTime(0))

    But it doesn’t work. It tells me that the property ‘value’ does not exist!? What have I missed…?

  • Walter Soyka

    January 31, 2023 at 1:30 am

    The layer space transform returns a point, not a property — so value and valueAtTime() have no meaning.

    However, toComp() accepts a second, optional parameter for time.

    Try this:

    target = thisComp.layer("Target");
    value + target.toComp(target.anchorPoint) - target.toComp(target.anchorPoint, 0);
Viewing 1 - 8 of 8 posts

Log in to reply.

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