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

Help With a script

New Here ,
Feb 26, 2025 Feb 26, 2025

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);

TOPICS
Expressions
117
Translate
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 ,
Feb 26, 2025 Feb 26, 2025

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.

 

 

 

Translate
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 ,
Feb 26, 2025 Feb 26, 2025

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).

 

 

Translate
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 ,
Feb 26, 2025 Feb 26, 2025

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

 

Translate
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 ,
Feb 26, 2025 Feb 26, 2025
LATEST

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)};

 

 

Translate
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