Activity › Forums › Adobe After Effects Expressions › Inertial decay of position
-
Inertial decay of position
Posted by Navarro Parker on March 12, 2013 at 10:52 pmI’m trying to replicate the motion of an iPad flick scroll. If I have a beginning and end position keyframe, I’d like an expression to continue the motion in the same direction but slowly brake/decay until it stops moving.
I’d like to define a stopping distance in frames/time. (such as: keep skidding for 15 frames after you hit the last position keyframe. But at the 16th frame, be at a complete dead stop)
I’d really appreciate some assistance. (A Google search only yielded elastic bouncy expressions)
Chris Thomas replied 7 years, 2 months ago 4 Members · 7 Replies -
7 Replies
-
Todd Kopriva
March 13, 2013 at 12:01 amThis script makes such things easy:
https://aescripts.com/ease-and-wizz/———————————————————————————————————
Todd Kopriva, Adobe Systems Incorporated
After Effects quality engineering
After Effects team blog
——————————————————————————————————— -
Navarro Parker
March 13, 2013 at 6:35 pmThanks Todd. Yeah, I’ve been using E&W for years. Not exactly what I’m asking for.
-
Dan Ebberts
March 14, 2013 at 11:49 pmI’ve been thinking about this off and on, and it turns out that it’s trickier than it seems. But I think I’ve got something that works if you’re willing to accept a sine ease. This assumes you have two keyframes and the ease will be applied after the second keyframe so that the overshoot ease is finished by the duration defined by variable frames:
frames = 15; // overshoot framesif (numKeys == 2){
t2 = key(2).time;
if (time < t2){
value
}else{
ot = framesToTime(frames);
freq = 1/(4*ot);
t = Math.min(ot,time-t2)
amp = velocityAtTime(t2 - .001);
w = freq*Math.PI*2;
valueAtTime(t2) + amp*Math.sin(t*w)/w;
}
}else
value
Dan
-
Navarro Parker
March 15, 2013 at 6:13 pmThanks Dan. Yeah, this behaves differently than I imagine. That sine falloff is a lot “slippery-er” than I expect. Layers just want to slider off my page with the smallest push. Reducing the overshoot frames makes it brake unnaturally.
Hmmmm… I guess I want a more graceful braking. I’m scrolling through my iPod playlist. I can give a quick flick, and it’ll scroll very fast, but then gently brake to a complete stop. Fiddling with your expression a little, I can’t seem to get short fast motion with that perfect de-acceleration.
-
Dan Ebberts
March 15, 2013 at 11:17 pmI don’t know if this is headed in the right direction, but here’s another version with an exponential ease. Variable damp adjusts how fast it slows down:
damp = 5;if (numKeys == 2){
t2 = key(2).time;
if (time < t2){
value
}else{
t = time - t2;
amp = velocityAtTime(t2 - .001);
valueAtTime(t2) + amp*(1-1/Math.exp(t*damp))/damp
}
}else
value
Dan
-
Chris Thomas
January 16, 2018 at 6:52 pmI know this has been closed for quite some time, but I thought I’d try a quick follow-up.
I’ve been using this script for a few years for UI/UX work and it’s absolutely wonderful. However I’m desperate for a version that allows you to add multiple instances of this movement on a single object. As it stands, you must add a parented null (or similar) every time you want to scroll again. As I’m sometimes doing this 10 or more times, it gets very complicated very quickly.
Would love to know if there’s a way to adapt this!
Reply to this Discussion! Login or Sign Up