Activity › Forums › Adobe After Effects Expressions › Alternative to toComp
-
Alternative to toComp
Posted by Navarro Parker on June 13, 2013 at 12:41 amIs there an alternative expression to the standard 3D Null to 2D position code:
L = thisComp.layer(“NULL”);
L.toComp(L.anchorPoint)I’m getting a strange behavior from a 3D null that moves so far off the screen, that the layer with this expression is moving off screen, but looping back around.
Darby Edelen replied 13 years, 2 months ago 2 Members · 5 Replies -
5 Replies
-
Darby Edelen
June 13, 2013 at 4:31 pmI’ve seen this happen when the 3D Null moves behind the camera. In those cases I usually check to see if the 3D Null is behind the camera and if it is I move the result of the expression to an arbitrary off-screen location like [-3000,-3000].
That’s a general idea that may work in a few different circumstances.
Darby Edelen
-
Navarro Parker
June 13, 2013 at 7:10 pmWhat’s the expression to check if a null is behind the camera?
-
Darby Edelen
June 13, 2013 at 11:46 pmHere’s a sample that uses the active camera and tests the layer the expression is applied to:
c = thisComp.activeCamera;
p = toWorld(anchorPoint);
cp = c.fromWorld(p);
if(cp[2] <= 0) behindCam = true;
else behindCam = false;
Darby Edelen
-
Navarro Parker
June 14, 2013 at 5:13 pmHey, I’m getting an error: expression results must be of dimension 2, not 1
Here’s a test project file to illustrate the original problem (for anyone wondering):
https://www.mediafire.com/download/bk0grfxawg0059w/3Dnull-looparound.aep
-
Darby Edelen
June 15, 2013 at 7:09 pmIn your case you could apply this to the opacity of the “pre.Mini Marker” pre-comp:
c = thisComp.activeCamera;
L = thisComp.layer("Null E");
p = L.toWorld(L.anchorPoint);
cp = c.fromWorld(p);
if(cp[2] <= 0) 0;
else value;This would make the layer invisible when it is behind the camera. The position values will still be incorrect but the layer will not be visible.
If you need the position to be offscreen then you can replace the position expression you’re currently using with this one:
c = thisComp.activeCamera;
L = thisComp.layer("Null E");
p = L.toComp(L.anchorPoint);
cp = c.fromComp(p);
if(cp[2] <= 0) [-5000,-5000];
else p;
Darby Edelen
Reply to this Discussion! Login or Sign Up