Activity › Forums › Adobe After Effects Expressions › Keeping an Object between two nulls?
-
Keeping an Object between two nulls?
Posted by Jerry Fines on October 31, 2008 at 11:37 pmIs there an expression that would keep an objects position between two nulls?
Pete Burges replied 2 years, 10 months ago 3 Members · 2 Replies -
2 Replies
-
Kevin Camp
November 1, 2008 at 12:21 amsomething 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 pmI 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
Reply to this Discussion! Login or Sign Up