Activity › Forums › Adobe After Effects Expressions › elastic and bounce expressions
-
elastic and bounce expressions
Posted by Thomas Passow on December 11, 2007 at 8:55 pmHi,
does anyone happen to know of expressions that mimic the easing in Flash for elastic and bounce easing types? (I believe Flash used Robert Penners math–but don’t quote me on that)
thanks,
t
Andy Engelkemier replied 14 years, 3 months ago 3 Members · 3 Replies -
3 Replies
-
Filip Vandueren
December 12, 2007 at 1:33 amThe basic formula for 2d position springiness is this:
inertia = 0.95;
k= 0.10;start=position;
will=[0,0];for (j=0; j<=time; j+=thisComp.frameDuration) { target=thisComp.layer("ball 2").position.valueAtTime(j); diff = (target-start); will = [will[0]*inertia + diff[0]*k , will[1]*inertia + diff[1]*k] start += will; } start; Dan has a different one on his site, that allows for having the spring to have a certain length when rested: https://www.motionscript.com/design-guide/elastic.html
-
Thomas Passow
January 18, 2008 at 1:33 amThanks Filip! by splitting my layer, I was able to get the action of the bounce to look quite good with your expression.
-
Andy Engelkemier
February 6, 2012 at 4:51 pmI was looking for this, but I knew there was something I was missing. Although this post works, this might be a little better if it works for your use (I know this is old, but it might help people like myself find what they need):
The script stops analyzing all previous frames once the bounce stops.
Here’s the code (apply it directly to the layer you’re animation).
// Inertial Bounce (moves settle into place after bouncing around a little)
n = 0;
if (numKeys > 0){
n = nearestKey(time).index;
if (key(n).time > time){
n--;
}
}
if (n == 0){
t = 0;
}else{
t = time - key(n).time;
}if (n > 0){
v = velocityAtTime(key(n).time - thisComp.frameDuration/10);
amp = .05;
freq = 4.0;
decay = 2.0;
value + v*amp*Math.sin(freq*t*2*Math.PI)/Math.exp(decay*t);
}else{
value;
}
Reply to this Discussion! Login or Sign Up