ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Move a layer up or down in index when zRotation exceeds or falls below certain value?

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Casey Labatt-Simon
Move a layer up or down in index when zRotation exceeds or falls below certain value?
on Oct 20, 2019 at 2:35:34 pm

Hi all! I have a mildly complicated question.

I'm creating an animation with a whole bunch of different cubes, in an isometric perspective, all rotating and moving around. I'm attempting to use Essential Graphics to be able to change how each cube looks from one master composition.

Because of the isometric perspective, when the cube rotates beyond 180 degrees, the index of the sides of the cube need to be switched so they display in the correct order. Here's a photo to demonstrate what happens if the layer order is not switched: the right side of the cube shows through the left side at certain degrees.

I've attempted to write an expression to switch the layer order of the "Right Side" and "Left Side" layers using the moveBefore() function whenever the zrotation of the top side of the cube exceeds 180° but I can't get it to work. One other problem I'm facing is exactly where to put the expression as well. I've never dealt with expressions other than ones that directly affect the effect they're placed on (I.e. looping expression on a rotation) and index isn't something you can directly place an effect on so I have no idea where to even start here.

Here's the preliminary expression I was thinking might work, but does not:


var rotationval = thisComp.layer(“Top Pattern”).effect(zRotation)

rotationval > 180 ? thisComp.layer(“rightPattern”).moveBefore() : thisComp.layer(“rightPattern”).moveAfter()


Would appreciate any help here.


Return to posts index

Dan Ebberts
Re: Move a layer up or down in index when zRotation exceeds or falls below certain value?
on Oct 20, 2019 at 3:31:01 pm

moveBefore() works with scripting, not expressions. Also, expressions can only affect the property hosting the expression, so there's no way for an expression to affect a layer's index.

If you've constructed a cube out of 3D layers though, it seems like the "stacking" should take care of itself, unless you've done something to break the 3D (like put 2D layers between the 3D layers).


Dan



Return to posts index

Casey Labatt-Simon
Re: Move a layer up or down in index when zRotation exceeds or falls below certain value?
on Oct 20, 2019 at 10:01:23 pm

Ahh I gotcha. For some reason when I rotate it, despite being 3D layers, it definitely doesn't just take care of itself. It definitely has something to do with the layer order because when I swap the layers around the issue in the photo in my post fixes itself. I guess that's a post for a separate subforum. Thank you for the reply!!


Return to posts index


Dan Ebberts
Re: Move a layer up or down in index when zRotation exceeds or falls below certain value?
on Oct 20, 2019 at 10:07:24 pm

There are quite a few things that can mess up the interaction of 3D layers. See if any of this applies to your situation:

https://helpx.adobe.com/after-effects/using/3d-layers.html#3d_layer_interac...

Dan



Return to posts index

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