In After Effects I am trying my hands at this

and would like to add a random number between 45 and 55 in the upper right corner, which should change each second.

If I use Math.round(random(45,55)) I am getting pretty close, but the number updates maybe 20 times a second making it unusable. Is there a way to control how often a new number is generated? Is there another way to do this?

Just to clarify, I want sort of what is already in wiggle, where wiggle(1,30) wiggles once a second.

1 Answer 1


random updates at the sub-frame level (so its value actually changes even during a frame, for example when motion blur is on. You can see this as you zoom in on the graph editor of a property with a random value, it keeps changing as it zooms and the time is sub-sampled more).

To force it to update only once a second you need to use the seedRandom function, with the timeless attribute set to true, and a seed that changes every second. Using Math.floor(time) will return a value that increases once every second, on the second.

So something like:

seedRandom(Math.floor(time), timeless = true);

will create a random value that stays constant for 1 second, and

var holdTime = 5;
seedRandom(Math.floor(time/holdTime), timeless = true);

will stay constant for 5 seconds - you can change the value of the variable holdTime to control how long the value holds for. For example to change once every frame, but not during sub-frame intervals set it to holdTime = thisComp.frameDuration;

  • 1
    If you want eg. 5 seconds, it's time/5 Aug 2, 2017 at 10:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.