Skip to main content
Orbit-Monkey
Inspiring
May 19, 2015
Answered

Is there a way to change expression values per keyframe?

  • May 19, 2015
  • 3 replies
  • 3462 views

I'm using an bounce/overshoot expression on the position property of an animated element.  On big moves, I want the bounce value to be higher - but on smaller movements I don't want it so dramatic.  It seems like the expression is independent of the keyframes - and if change a variable in the expression it changes it for the entire timeline - vs just certain keyframes.  Is this possible?

This topic has been closed for replies.
Correct answer Mathias Moehl

You can also use ExpressionTimeline to combine several instances of your expression with different parameter settings.#

Here is a tutorial showing how to use ExpressionTimeline:

tutorial-thumbnail-expression-timeline.jpg?itok=Gid_PJPb

Limit Expressions to a Range of Keyframes with Expression Timeline | mamoworld

3 replies

Mathias Moehl
Mathias MoehlCorrect answer
Community Expert
May 20, 2015

You can also use ExpressionTimeline to combine several instances of your expression with different parameter settings.#

Here is a tutorial showing how to use ExpressionTimeline:

tutorial-thumbnail-expression-timeline.jpg?itok=Gid_PJPb

Limit Expressions to a Range of Keyframes with Expression Timeline | mamoworld

Mathias Möhl - Developer of tools like BeatEdit and Automation Blocks for Premiere Pro and After Effects
Orbit-Monkey
Inspiring
May 20, 2015

Yes - this is exactly what I was looking for. Thank you!

Dan Ebberts
Community Expert
May 19, 2015
Orbit-Monkey
Inspiring
May 19, 2015

Dan - its your script on that page that I'm actually using! It's great...  But Maybe I'm not implementing it correctly.   How can i change the values per keyframe vs the timeline as a whole?

Dan Ebberts
Community Expert
May 19, 2015

I suppose you could create frequency and decay arrays, with entries for each keyframe and modify the expression to something like this:

freqArray = [3,2,1,4];

decayArray = [5,6,7,6];

n = 0;

if (numKeys > 0){

  n = nearestKey(time).index;

  if (key(n).time > time) n--;

}

if (n > 0){

  freq = freqArray[Math.min(n-1,freqArray.length-1)];

  decay = decayArray[Math.min(n-1,decayArray.length-1)];

  t = time - key(n).time;

  amp = velocityAtTime(key(n).time - .001);

  w = freq*Math.PI*2;

  value + amp*(Math.sin(t*w)/Math.exp(decay*t)/w);

}else

  value

Dan

Szalam
Community Expert
May 19, 2015

It depends on your expression and how it's written.

For stuff like this, I'll often make some of the numbers in an expression be variables which are tied to Expression Control effects.