Skip to main content
Participating Frequently
Mar 4, 2024 12:24 PM UTC
Answered

Changing x position of last keyframe using a slider for template

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 is closed to new replies. Start a new post to keep the conversation going.
Airweb_AECorrect answer
Legend
Mar 5, 2024 12:56 AM UTC
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()

4 replies

Mylenium
Legend
Mar 4, 2024 4:39 PM UTC

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

Translate
Participating Frequently
Mar 4, 2024 10:36 PM UTC

Hi Mylenium, 

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

Thanks

Translate
Airweb_AECorrect answer
Legend
Mar 5, 2024 12:56 AM UTC
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()

Translate