Copy link to clipboard
Copied
Hello,
Im trying to create an object that moves in the opposite direction and at 95% of the rate of an animated point.
I have set up sliders on my point with controls for both the X and Y axis - and am currently struggling to write the expressions for my object.
So far, I have:
X=thisComp.layer("CONTROLS").effect("Centre
Y=thisComp.layer("CONTROLS").effect("Centre
if (X < 2500){
(thisComp.layer("CONTROLS").effect("Centre
}else if{
(thisComp.layer("CONTROLS").effect("Centre
}else{
2500;}
if (Y < 2500){
(thisComp.layer("CONTROLS").effect("Centre
}else if{
(thisComp.layer("CONTROLS").effect("Centre
}else{
2500;}
[X,Y];
Hi!
Dan is right, as usual 🙂
You have to declare variables that you can modify and use.
You set this expression in a position property, right?
I think you should try this way (at least if I understand what you're trying to do) :
//your animated values
X=thisComp.layer("CONTROLS").effect("Centre
Y=thisComp.layer("CONTROLS").effect("Centre
//Your variables
X2 = 2500;
Y2 = 2500;
if (X < 2500){
X2 = X*0.95;
} else if (here, another condition, like "X > 2500") {
X2 = X*1.05);
}
if (Y < 2
...Copy link to clipboard
Copied
I can't quite figure out what you're trying to do, but I'm pretty sure you're on the wrong track. In your expression, everything between the second line and the last line will have no effect on the result. Maybe more detail about what you're trying to accomplish...
Dan
Copy link to clipboard
Copied
Hi!
Dan is right, as usual 🙂
You have to declare variables that you can modify and use.
You set this expression in a position property, right?
I think you should try this way (at least if I understand what you're trying to do) :
//your animated values
X=thisComp.layer("CONTROLS").effect("Centre
Y=thisComp.layer("CONTROLS").effect("Centre
//Your variables
X2 = 2500;
Y2 = 2500;
if (X < 2500){
X2 = X*0.95;
} else if (here, another condition, like "X > 2500") {
X2 = X*1.05);
}
if (Y < 2500){
Y2 = Y*0.95;
} else if (here, another condition, like "Y > 2500") {
Y2 = Y*1.05;
}
[X2,Y2]; //return your 2D value
Cheers,
François
Copy link to clipboard
Copied
Thank you! This seems to have worked!
Could you possibly explain to me why I needed to use the variables X2 and Y2?
Many thanks
Ollie
Copy link to clipboard
Copied
Well, you want to return a 2D value.
Your expression was returning [X,Y], which is 2D, but just contains your "control" values.
And all the IF ELSE code was actually not affecting the result (except throwing error)
If you want to return the "computed" values (X2 and Y2) you have to:
1_declare X2 and Y2
2_modify (or assign value to) X2 and Y2 according to your IF ELSE condition
3_return X2 and Y2
Having declared X2 and Y2 in the beginning lets you modify them independently.
But you could also have something like this without declaring X2 and Y2:
if (X < 2500 && Y < 2500) {
[X*.95, Y*.95];
} else if (X > 2500 && Y < 2500) {
[X*.1.05, Y*.95];
} else if ... and so on