-
Odometer- numbers “click” into place
I’m trying to create an odometer-style counter that is counting days (2 digits, loops back to 0 after 30), months (2 digits, loops back to 0 after 11), and years (1 digit). It only has to go up to 5 years. I’ve found various solutions to a basic odometer, but they all just consistently roll all the numbers. I need the numbers to wait until 3-4 frames before they are supposed to appear, then slide quickly into place. Ideally they could have a slight bounce to them when they land. I found this expression from Dan Ebberts on the forum that almost does what I need, but with markers. I’ve applied it to the Offset Effect on a very tall precomp with numbers 0-9 vertically. They are spaced 460 pixels apart:
sx = 460; // slide distance
sd = .25; // slide durationm = thisLayer.marker;
y = 0;
if (m.numKeys > 0){
n = m.nearestKey(time).index;
if (time < m.key(n).time) n--;
if (n > 0){
t = time - m.key(n).time;
y = ease(t,0,sd,(n-1)*sx,n*sx);
}
}
value + y
I am going to be ramping the speed of this odometer, stopping on each complete year, so it needs to be controlled with a slider and not markers (unless there is a way to automate the creation of markers based on slider keyframes?). I also want it to feel like it is clicking/vibrating into place, so adding a decaying wiggle would be icing on the cake! I usually use something like this which works for linear keyframes, but not if the animation is created with expressions I found out:
amp = 1;
freq = 5.0;
decay = 8.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){
v = velocityAtTime(key(n).time - thisComp.frameDuration/10);
value + v*(amp*.1)*Math.sin(freq*t*2*Math.PI)/Math.exp(decay*t);
}else{value}