Created
November 10, 2017 21:35
-
-
Save spencejs/02abd06b4750feb5aea7720cea0865a5 to your computer and use it in GitHub Desktop.
AE - Inertial Bounce
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bounces = 1; //total number of bounces | |
duration = .5; //duration of each bounce in seconds | |
amp = 1.5; //multiplier for incoming velocity used in bounce | |
decay = 2; //exponential decay of bounce height | |
n=0; | |
if(numKeys>0){n=nearestKey(time).index;if(key(n).time>time){n--;}} | |
n==0?t=0:t=time-key(n).time; | |
freq=1/duration; | |
mult = (bounces-Math.floor(t*freq))/bounces; | |
if (n>0 && mult>0) { | |
v=velocityAtTime(key(n).time-0.001)*amp; //velocity to use | |
b=Math.abs(Math.sin(freq*t*Math.PI))*Math.pow(mult,decay); //bounce calculation | |
value-v*b; | |
} else {value;} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment