ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

# Odometer- numbers "click" into place

FAQ   •   VIEW ALL
 Odometer- numbers "click" into place on Jan 30, 2019 at 8:04:42 pm

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 duration m = 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} ```

 Re: Odometer- numbers "click" into placeon Jan 31, 2019 at 12:13:18 am

Ok, I realize this is a tall order. I think I figured out a work-around for the overshoot aspect of it. Apparently this is pretty difficult to do with expressions vs keyframes.
So, my basic idea right now is to use integers of the slider to "trigger" the scrolling animation. I'm just at a bit of a loss as to how to do this. I think I can figure out how to get each digit doing the proper thing if I can get one of them working this way.
Thanks!

 Re: Odometer- numbers "click" into placeon Feb 4, 2019 at 4:50:41 pm

Hello Nate,

thinking about this - would you mind sharing a comp structure which you have with the numbers?

Technically, I would be thinking about pre-compositing all the digits and then control them by time remapping. Seeing how you have them laid out, could help to suggest approach for your setup, or provide other workaround.

Cheers!

Find out more:
After Effects Tutorials: motion design, expressions, scripting.

 Re: Odometer- numbers "click" into placeon Feb 4, 2019 at 6:10:13 pm

Thanks for the interest! Here is my project file. I've sort of hacked it together, but still not completely happy with it. I am using a Time Remapping expression I found on another post here. The main issue is that it doesn't work very well with the bounce/vibration that I want when the numbers land. I'm also keyframing the 10s digit of the month and the year digit manually.
Here's the project file. Thanks!

13075_daymonthyearodometerforcowv1.aep.zip

 Re: Odometer- numbers "click" into placeon Feb 4, 2019 at 6:43:18 pm

I thought I should explain a bit further. First of all, the days can go up to 30 every month (that doesn't have to be accurate). Then the months should got up to 11 before rolling over to "0" when the year digit advances.
When I time remap the precomped animation of the numbers bouncing into place, the bounce and the vertical movement becomes either too slow or too fast. I tried controlling the bounce expression in the precomp with sliders in the main comp, but the timing of the keyframes in the main comp just coincides with the same timecode in the precomp, which effects it every time it loops- sort of baking it in- not very helpful. I'd love for it to be consistent every time it clicks how fast it moves into place and how much/how fast it vibrates.
I had an idea to scrap the time remapping and use the Offset effect on a still Precomp that had all the necessary digits vertically. But I couldn't figure out how to adapt the time remapping expression to get it working. I thought there could be a way for the expression to trigger almost a one frame change when the slider gets to an integer, then smooth that out with the smooth(x,x) function and then add my bounce on top of that. I'd even be willing to add the bounce using a marker-based expression rather than velocity-based. Something like this:

```amp=20; //amplitude (pixels) freq=2; //frequency (cycles per second) decay=3.5; //decay time (seconds) // find previous marker n = 0; // assume haven't reached a marker yet if (marker.numKeys > 0){ n = marker.nearestKey(time).index; if (marker.key(n).time > time){ n--; } } if (n > 0) t = time - marker.key(n).time else t =0; a = amp*Math.sin(freq*t*Math.PI*2)/Math.exp(decay*t); a + value ```

 Re: Odometer- numbers "click" into placeon Feb 5, 2019 at 11:35:43 am

Hey Nate,

thanks for sharing this through. Since its a bit complex in logic and requires digging through, I will look at it a bit later and provide my suggestions if any. For now, few quick insights I noticed:

1. Don't use 'Force Motion Blur' nor 'Native Motion Blur' or any 'Blur Effect' while the project is in early WIP status. It slows down previews and reduces efficiency of your work.
2. The same applies for 'bounce/overshoot' effects, which are more like 'nice to have' features. Adding complexities as you go along would help to build it step by step, nailing technique one at a time towards the end result.

Cheers!

Find out more:
After Effects Tutorials: motion design, expressions, scripting.

 Re: Odometer- numbers "click" into placeon Feb 5, 2019 at 1:42:02 pm

Thanks for taking a look! Good point with not using bells and whistles until the basics are working. I did make sure to add that stuff after I had some of it working. The thing is, the motion blur was necessary for the final, and I found that, depending on what motion blur technique was used, I would get artifacts when it looped. The frame between 9 (the last digit in my precomp) and 0 would be a complete blur- I think because it was almost like it was rewinding from the end to the beginning over one frame. So I was trying to find a solution that would work with my expressions setup since, without motion blur, those fast-moving numbers would look terrible.
Anyway, let me know if you figure anything out!

 Re: Odometer- numbers "click" into placeon Feb 10, 2019 at 11:25:41 am

Hey Nate,

Thanks for your response, totally understand. I looked through the assets you are using and here are few insights to share with you, through my perspective:

General:
1. For smooth option, instead of using 'Ease and Wizz', it would be a lot better to tweak graph editor to get a 'feel' you are after. (It would be faster processing as well). Select all keyframes, go to graph editor, and edit 'Speed' graph handles.
2. For shutter expression if you keep it as it is - link 'amp', 'freq' and 'decay' with sliders, that you could affect all of their bouncing between various comps, at once.
3. The same goes for 'mult' value of 'Speed' expression. If you add a slider, you could control it with animation, rather than sticking to 0.5 value during whole time. This would add extra control over speed.
4. With custom graph editor handles editing, you could achieve more 'delayed' feeling of rolling numbers, rather than committing to EaseWizz. (This would be especially relevant to 'tens', which won't start rolling too early as it is now)
5. In ideal scenario, instead of using all numbers in a single layer in each comp, I would suggest pre-composing all numbers individually and then aligning them in Y one after another by parenting to Y position.

I will call 'first' & 'second' digits as you named them in the project.

Days:
1. Second digit (of tens) abruptly goes from 3 to 0 in three frames time gap, which causes a jump. Extend composition to 4s. Then, edit Time Remap expression to reflect the new length of comp.

Months:
1. First digit does not reach 'twelve' value. Meaning, it should have values of
'0 1 2 3 4 5 6 7 8 9 0 1 2 0'
'0 1 2 3 4 5 6 7 8 9 0 1 0'

Could you clarify the following:
1. Why you decided to set 'Stopper' the way its done?
2. Would you interchange between 'Smooth' & 'Shutter' versions during the same execution? (Since keyframes were set for their checkboxes)

Cheers.

Find out more:
After Effects Tutorials: motion design, expressions, scripting.