Skip to main content
Participating Frequently
Mar 25, 2024 5:40 PM UTC
Answered

After effects Dropdown and slider expression to change position of a layer

I am creating a setup in after effects where I want to change a position according to a slider and dropdown values. Using below expression for the same 

mDrop = comp("Character Builder").layer("Body Type").effect("Body Type")("Menu");
s = thisComp.layer("Turn Body & Head").effect("Turn Body")("Slider");
x = transform.position[0];
y = transform.position[1];
[x,y];
if (s == 0 && mDrop == 1) {[x,y]}
else if (s == 1 && mDrop == 1) {[x-110,y-11]}
else if (s == 2 && mDrop == 1) {[x-325,y]}
else if (s == 3 && mDrop == 1) {[x-526,y-94.5]}
else if (s == 4 && mDrop == 1) {[x-598.,y-106.1]}
else if (s == -4 && mDrop == 1) {[x-598.,y-106.1]}
else if (s == -3 && mDrop == 1) {[x-495,y-79]}
else if (s == -2 && mDrop == 1) {[x-299,y]}
else if (s == -1 && mDrop == 1) {[x-71,y-14]}
else if (s == 1 && mDrop == 2) {[x-41.5,y+62.5]}



There will be more dropdown values till 5 and I want to change the postion if mentioned slider and dropdown values matches

 

This topic is closed to new replies. Start a new post to keep the conversation going.
Dan Ebberts
Dan EbbertsCorrect answer
Community Expert
Mar 25, 2024 7:09 PM UTC

What are the current values of the menu and the slider?


Try adding this as the last line and see if it gets rid of the error:

else value

10 replies

Dan Ebberts
Community Expert
Community Expert
Mar 25, 2024 6:36 PM UTC

I'm guessing you have a question, correct? From your screen cap, it looks like your expression generates an error. What's the error message?

Translate
Participating Frequently
Mar 25, 2024 6:45 PM UTC

Yes sorry it was a question. Error says "Undefined value used in expression"

I am not good with expressions. Any help will be a life saver.

Translate