ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Linking the X and Y scale properties of shape layers to a slider with expressions.

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Jay Sway
Linking the X and Y scale properties of shape layers to a slider with expressions.
on Jul 9, 2018 at 12:51:12 pm
Last Edited By Jay Sway on Jul 9, 2018 at 4:18:50 pm

Hey all, this is my first CC post. I'm pretty brand new to manual rigging (I've used some automated plug-ins like Joysticks and Sliders), so hopefully this is a pretty easy question to answer.

I need to animate a very simple box rig in 2D space, but with the illusion of 3D. It needs to be able to rotate 90º in any direction. It will have different design on the different sides, but that's beside the point. The way I'm attempting to do this is with square shape layers which transform scale and position based on sliders they are attached to.

I know I need to use the linear expression, I'm just having trouble making it work properly. For example, if the box isn't rotated at all, all you would see is the front square layer. The sliders would all be set to "0" on a scale from -100 to 100. If I rotate the cube all the way to the left, I want to set the left/right slider to -100, which would scale down the front square vertically to 0, while also expanding the right side square vertically from 0 to 100. If I want to rotate the cube upwards 90º, I would set the up/down slider to 100 and it would scale down the front square to 0 horizontally, while scaling the bottom square up horizontally from 0 to 100. Is this making sense? I'm having trouble understanding how these expressions should be phrased. Anyone able to help?

UPDATE: Here is what I've been trying to no avail. I'm sure I'm making some rookie errors here, I'm not sure how to fix them.

I have a left/right slider (Called "Head Y-Axis (L/R)") with values from -100 to 100. the expressions Ive been trying so far look like this, which get close, but not quite there:

temp = thisComp.layer("Head Control").effect("Head Y-Axis (L/R)")("Slider");
xVal = linear(temp,-100,0,0,100);
[xVal,100];

temp = thisComp.layer("Head Control").effect("Head Y-Axis (L/R)")("Slider");
xVal = linear(temp,0,100,100,0);
[xVal,100];

Anyone see what I'm doing wrong here?

Sorry, one more UPDATE:

I was able to find the expression that I needed, but I do not really understand the language well and am wondering if anyone else could help explain what is going on here. This expression ended up doing the trick:

x = thisComp.layer("Head Control").effect("Head Y-Axis (L/R)")("Slider");
xVal = x < 0 ? linear(x,-100,0,0,100) : linear(x,0,100,100,0);
[xVal,100];

I am not sure what "x < 0 ?" on the second line means. Could anyone help me understand what this expression is saying?


Return to posts index

Dan Ebberts
Re: Linking the X and Y scale properties of shape layers to a slider with expressions.
on Jul 9, 2018 at 4:46:35 pm

Play around with this for scale:

temp = thisComp.layer("Head Control").effect("Head Y-Axis (L/R)")("Slider");
a = linear(temp,-100,100,-Math.PI/2,Math.PI/2);
s = Math.abs(Math.cos(a));
[value[0]*s,value[1]]

and this for position:

temp = thisComp.layer("Head Control").effect("Head Y-Axis (L/R)")("Slider");
a = linear(temp,-100,100,-Math.PI/2,Math.PI/2);
offset = (width/2)*Math.sin(a);
[value[0]+offset,value[1]]


Dan



Return to posts index

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