Copy link to clipboard
Copied
I have two text layers, (Text 1 and Text 2) each is controlled by Slider to change the text, now the script work as it swap their position the higher number always remain at top, but if someone can help the position swap too quick, how can i easy ease them, like it change in 5 frames
script :
slider1 = thisComp.layer("Text 1").effect("Slider 1")("Slider")
slider2 = thisComp.layer("Text 2").effect("Slider 2")("Slider")
originalPos1 = [value[0], 1002.753];
originalPos2 = [value[0], 1349.9595];
// Determine target position based on slider values
targetPos = (slider2 > slider1) ? originalPos1 : (slider2 < slider1 ? originalPos2 : value);
// Smooth transition
smoothTime = 2; // Adjust for slower or faster transition
currentTime = time;
previousPos = valueAtTime(currentTime - smoothTime);
linear(currentTime, currentTime - smoothTime, currentTime, previousPos, targetPos);
Copy link to clipboard
Copied
Have you tried:
ease(currentTime, currentTime - smoothTime, currentTime, previousPos, targetPos);
If you need a more specific duration, I think it's possible, but takes a bit of digging out the code.
Copy link to clipboard
Copied
I've just recreated your comp, and yeah, ease will not work. But I can see the issue with your current code.
With expressions, each frame runs the code as new, so in the linear function, currentTime is always updating.
Where you have currentTime - smoothTime, that's always going to be 2 seconds from the currentTime now. You need to figure out a fixed moment in the timeline to drive the linear expression (then the ease() function might improve things afterwards).
Copy link to clipboard
Copied
OK, this is got my attention.
Turns out when checking the documentation ,you don't need time values for the linear or ease expressions:
https://helpx.adobe.com/uk/after-effects/using/expression-language-reference.html
You can just write:
ease(time, previousPos, targetPos);
But it was only working on the first value change.
previousPos = transform.position.valueAtTime(time - smoothTime);
I think this problem is connected to this comparison line:
targetPos = (slider2 > slider1) ? originalPos1 : (slider2 < slider1 ? originalPos2 : tempVal);
As the change is happening during the 2 second window of smoothtime
Copy link to clipboard
Copied
RIP your inbox / notifications - sorry.
Linear and Ease appear to only run once per layer, unless you place them inside some sort of condition, e.g.:
if (value <=15){linear(value,0,15,0,0)};
if (value <= 20){linear(value,15,20,30,80)};
if(value > 20){linear(value,20,30,80,100)};
Find more inspiration, events, and resources on the new Adobe Community
Explore Now