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
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
Try adding this as the last line and see if it gets rid of the error:
else value
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?
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.
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.
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?
Copy link to clipboard
Copied
Copy link to clipboard
Copied
What are the current values of the menu and the slider?
Copy link to clipboard
Copied
Try adding this as the last line and see if it gets rid of the error:
else value
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.
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.
Copy link to clipboard
Copied
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.