-
Move a layer up or down in index when zRotation exceeds or falls below certain value?
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.