FORUMS: list search recent posts

Referencing null movement with relative position offset

COW Forums : Adobe After Effects

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Mark Warner
Referencing null movement with relative position offset
on Apr 3, 2014 at 11:58:23 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!


Return to posts index

Walter Soyka
Re: Referencing null movement with relative position offset
on Apr 3, 2014 at 2:44:28 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


Return to posts index

Mark Warner
Re: Referencing null movement with relative position offset
on Apr 4, 2014 at 9:49:18 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.


Return to posts index


Walter Soyka
Re: Referencing null movement with relative position offset
on Apr 7, 2014 at 6:50:27 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


Return to posts index

Mark Warner
Re: Referencing null movement with relative position offset
on Apr 8, 2014 at 9:25:15 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!


Return to posts index

Matt Davis
Re: Referencing null movement with relative position offset
on Apr 7, 2014 at 6:16:01 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.


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]