• Global community
    • Language:
      • Deutsch
      • English
      • EspaƱol
      • FranƧais
      • PortuguĆŖs
  • ę—„ęœ¬čŖžć‚³ćƒŸćƒ„ćƒ‹ćƒ†ć‚£
    Dedicated community for Japanese speakers
  • ķ•œźµ­ ģ»¤ė®¤ė‹ˆķ‹°
    Dedicated community for Korean speakers
Exit
1

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

Community Beginner ,
Mar 25, 2024 Mar 25, 2024

Copy link to clipboard

Copied

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 

Nishant29813557w8j1_0-1711388331892.png

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

 

TOPICS
Expressions

Views

350

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Mar 25, 2024 Mar 25, 2024

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

else value

Votes

Translate

Translate
Community Expert ,
Mar 25, 2024 Mar 25, 2024

Copy link to clipboard

Copied

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?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Mar 25, 2024 Mar 25, 2024

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Mar 25, 2024 Mar 25, 2024

Copy link to clipboard

Copied

I have added a slider and dropdown controller to control position of a layer, 
So if slider and dropdown condition matches, the position will be set to the mentioned x,y values.

But i am not able to make it work.

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 25, 2024 Mar 25, 2024

Copy link to clipboard

Copied

If you click into the expression, it should highlight a particular line where the error is. Can you post an image of that?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Mar 25, 2024 Mar 25, 2024

Copy link to clipboard

Copied

Nishant29813557w8j1_0-1711393554171.png

 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 25, 2024 Mar 25, 2024

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 25, 2024 Mar 25, 2024

Copy link to clipboard

Copied

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

else value

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Mar 25, 2024 Mar 25, 2024

Copy link to clipboard

Copied

When Dropdown value is 1 it works fine but when when i select any other dropdown options apart from 1, it shows the error.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 25, 2024 Mar 25, 2024

Copy link to clipboard

Copied

I get that error if the menu is set to the 2nd item and the slider is set to anything other than 1, because there is no code to handle that situation. The ending line I suggested should keep it from erroring out.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Mar 25, 2024 Mar 25, 2024

Copy link to clipboard

Copied

LATEST

Yessss, it worked, I guess I can add more condition to it now. THank you so much. I will try and reply if anything comes up.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines