Activity › Forums › Adobe After Effects Expressions › How to make a sliding number counter in After Effects
Tagged: Basic
-
How to make a sliding number counter in After Effects
Posted by Mohamed Imran on May 1, 2024 at 1:30 pmIs anyone know How to make a sliding number counter in After Effects with expression?
Mohamed Imran replied 2 years ago 3 Members · 4 Replies -
4 Replies
-
Mohamed Imran
May 2, 2024 at 6:41 amHi Dan Ebberts,
I meant a counter’s number sliding up or down while counting numbers, looks like this pic
-
David Conklin
May 2, 2024 at 8:30 pmThere’s not a silver-bullet expression you can apply to a single property to achieve this effect. Depending on how comfortable you are with expressions there are more- and less-complex ways to do it.
This might get you started:
1. On a new text layer, type the numbers 0-9 and then another 0, each on its own line.0
1
2
...
8
9
02. Make a new slider on the text layer.
3. Apply this expression to your text layer’s position:
const numberSlider = effect("Slider Control")("Slider");
const leading = text.sourceText.getStyleAt(0,0).leading;
value - [0, numberSlider * leading];A text layer’s leading is how many px tall 1 line is. So 1 * leading = height of 1 line. 5 * leading = height of 5 lines, etc.
4. Next, apply this expression to your Slider Control:
value % 10;Now, when you animate that slider, it should give you the correct digit up to 10. The expression we added to the slider effector makes the value “wrap” after 10, once it counts up to 9.999999 resets to 0 instead of becoming 1. This is essentially how you’d do you “ones” place. Think about how you might calculate a tens or hundreds place (hint: dividing by a factor of 10 and truncating decimals), that could be a good next step.
If you combo a couple of these together with some masks and a control layer and you’ve got a rig. There are probably ways to do this with an expression selector on a single text layer, but I don’t think the complexity merits the result.
Hope that helps get you started.
Cheers
-
Mohamed Imran
May 3, 2024 at 2:53 amThank you a lot, it helps to gain knowledge and continue my project.
excellent!
Reply to this Discussion! Login or Sign Up