Activity › Forums › Adobe After Effects Expressions › track nested child layer position
-
track nested child layer position
Posted by Todd Morgan on October 28, 2010 at 6:07 pmLooking all over but can’t find it… any insight on how to track a nested comp child layer? I have a main comp with a nest comp, and need a layer from the main comp to follow position of a child layer located in the nested comp.
Mark Ash replied 14 years, 4 months ago 3 Members · 8 Replies -
8 Replies
-
Dan Ebberts
October 28, 2010 at 6:58 pmTry this:
L1 = comp(“precomp name”).layer(“layer to track”);
P = L1.toWorld(L1.transform.anchorPoint);
L2 = thisComp.layer(“precomp name”);
L2.toComp(P);Dan
-
Todd Morgan
October 29, 2010 at 10:48 amdo i keep the ” when placing in precomp name? it works but only for the x-axis…
-
Todd Morgan
October 29, 2010 at 11:49 amI managed to find a shorter solution…
In the expression area for the position of my layer I need to transform so that it tracks with my precomp layer just below it:
this_comp.layer(“precomp”).source.layer(“layertotrackinprecomp”).position
and then adjust the anchor point of the layer that I am using this expression on. Do same with rotation and it works like a charm!
-
Mark Ash
March 28, 2012 at 1:01 pmhi there
i’ve been at this for hours now and can’t find the right solution. I have a null in a 2D comp which is parented to another layer (it’s part of the torso of a character puppet and parented to a controller).
this 2D character comp is within my 3D main comp as a 3D layer. i need to parent another 3D layer in the main comp (the arm) to the nested, parented 2D null (it’s an anchor for the arm).i can’t quite figure out the relative positions – it’s attached, just not correctly! the character comp layer is also parented to another 3D layer in the main comp (the boat it’s sitting in) which is throwing out the Z position.
i’d be hugely grateful for any help!
many thanks,
Mark
code below:
ancNull = comp("archie_row").layer("Torso_Arm_Anchor_NR");
ancNullPos = ancNull.toWorld(ancNull.transform.anchorPoint);
thisArchie = thisComp.layer("archie_row");
nullPos = thisArchie.toComp(ancNullPos);posX = nullPos[0];
posY = nullPos[1];
thisArchiePos = thisArchie.toWorld(thisArchie.position);
posZ = thisArchiePos[2];[posX, posY, posZ];
-
Dan Ebberts
March 28, 2012 at 5:16 pmIt’s hard to picture what you’re doing without a sketch, but what happens if you just do this?
ancNull = comp(“archie_row”).layer(“Torso_Arm_Anchor_NR”);
ancNullPos = ancNull.toWorld(ancNull.transform.anchorPoint);
thisArchie = thisComp.layer(“archie_row”);
thisArchie.toWorld(ancNullPos);Dan
-
Mark Ash
March 28, 2012 at 5:35 pmDan thank you so much for replying. That works great – it seems I’ve spent several hours staring at trees whilst standing in the wood! It did help to unparent the coded layer from “archie_row” tho, as was thereabouts without being there!
again many thanks. your tireless help and support do not go unnoticed or unappreciated. although this is my first question, it is certainly not the first problem you’ve solved via your help of other folk.
big up yerself.
Reply to this Discussion! Login or Sign Up