-
Inertial bounce with clamp
I’m using the classic inertial bounce expression on position and rotation properties, but want to clamp the max value to the value of the second keyframe. It would be like the layer hits a wall or rotates against a wall. I’ve found a solution or two, but nothing that seems to work universally without breaking.
Thanks,
Andrésamp = .1;
freq = 3.0;
decay = 9.0;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 && t < 1){
v = velocityAtTime(key(n).time - thisComp.frameDuration/10);
value + v*amp*Math.sin(freq*t*2*Math.PI)/Math.exp(decay*t);
}else{value}