Skip to main content
Participating Frequently
November 5, 2014
Frage

Creating a number counter that counts in increments of .05 in After Effects.

  • November 5, 2014
  • 1 Antwort
  • 4056 Ansichten

I need to create a number counter that counts in increments of .05 in After Effects.  Any advice on how to do this?

Many thanks!

Dieses Thema wurde für Antworten geschlossen.

1 Antwort

Tim Kurkoski
Adobe Employee
Adobe Employee
November 5, 2014

This is relatively easy to do with an expression on a text layer's Source Text property. Use the existing timeToFrames() method and divide by 2:


timeToFrames(t = time + thisComp.displayStartTime, fps = 1.0 / thisComp.frameDuration, isDuration = false)/2;

But if you don't want it to trim the decimal place off of integer values, use the toFixed() method.

halfFrames = (timeToFrames(t = time + thisComp.displayStartTime, fps = 1.0 / thisComp.frameDuration, isDuration = false))/2;

halfFrames.toFixed(1);

Just for kicks, I expanded a version that pads leading zeros for up to three pre-decimal digits:

halfFrames = (timeToFrames(t = time + thisComp.displayStartTime, fps = 1.0 / thisComp.frameDuration, isDuration = false))/2;

if (halfFrames >= 10 && halfFrames < 100) {

halfFrames = "0" + halfFrames.toFixed(1);

}

else if (halfFrames >= 0 && halfFrames < 10) {

halfFrames = "00" + halfFrames.toFixed(1);

}

else {

halfFrames.toFixed(1);

}

sylvviaAutor
Participating Frequently
November 6, 2014

thanks so much for the response.  I actually need to do a counter that goes from 0.00 to 1.30  in .05 increments.  So it would go: 0.00, 0.05, 0.10, 0.15   and so on up to 1.30.  Your above expressions count in .5 increments... I can't get my head around what I need to change to make it work..   any input would be appreciated

thanks!

Dan Ebberts
Community Expert
Community Expert
November 6, 2014

A source text expression like this should work:

rate = 10; // ticks per second

ticks = Math.floor((time - inPoint)*rate);

Math.min(ticks/20,1.3).toFixed(2)

Adjust the rate variable to suit your needs.

Dan