nearestKeyIndex = 0;
if (numKeys > 0){
nearestKeyIndex = nearestKey(time).index;
if (key(nearestKeyIndex).time > time){
nearestKeyIndex—;
}
}
if (nearestKeyIndex == 0) {
currentTime = 0;
} else {
currentTime = time - key(nearestKeyIndex).time;
}
if (nearestKeyIndex > 0 && currentTime < 1) {
calculatedVelocity = velocityAtTime(key(nearestKeyIndex).time - thisComp.frameDuration / 10);
amplitude = 0.06;反弹的力度越大,值越大,反弹越强烈
frequency = 2.0;频率,每秒反弹次数
decay = 6.0;衰减,值数越大,越快停止
value + calculatedVelocity amplitude Math.sin(frequency currentTime 2 Math.PI) / Math.exp(decay currentTime);
} else {
value;
}
回弹表达式一般用于:旋转、缩放、位置
表达式添加方法:
回弹表达式注意事项:
最后一个关键帧必须是匀速!