Skip to main content
Participating Frequently
March 4, 2024
Answered

Changing x position of last keyframe using a slider for template

  • March 4, 2024
  • 1 reply
  • 536 views

I've searched for an expression that will use a slider to change the x position on the last keyframe but can only seem to get it work on adjusting the first keyframes x position instead. 

Any help as to what I need to amend in the expression to get it work would be great. 


This topic has been closed for replies.
Correct answer Airweb_AE
firstValue = key(1).value[0];
sliderValue = effect("Slider Control")(1);

   x = linear(time, key(1).time, key(numKeys).time, firstValue, sliderValue);
// x = ease(time, key(1).time, key(numKeys).time, firstValue, sliderValue);
// x = easeIn(time, key(1).time, key(numKeys).time, firstValue, sliderValue);
// x = easeOut(time, key(1).time, key(numKeys).time, firstValue, sliderValue);
[x, value[1]]

In your screenshot you're not using a linear interpolation so you may need to use an ease() instead of linear()

1 reply

Mylenium
Legend
March 4, 2024

Your code makes no sense. The driver in a linear() function is time or another slider's input, not the property base value itself. Simply fix the function and it will work.

 

Mylenium

Participating Frequently
March 4, 2024

Hi Mylenium, 

If you could help me with what is correct that would be great. 

Thanks

Airweb_AECorrect answer
Legend
March 5, 2024
firstValue = key(1).value[0];
sliderValue = effect("Slider Control")(1);

   x = linear(time, key(1).time, key(numKeys).time, firstValue, sliderValue);
// x = ease(time, key(1).time, key(numKeys).time, firstValue, sliderValue);
// x = easeIn(time, key(1).time, key(numKeys).time, firstValue, sliderValue);
// x = easeOut(time, key(1).time, key(numKeys).time, firstValue, sliderValue);
[x, value[1]]

In your screenshot you're not using a linear interpolation so you may need to use an ease() instead of linear()