Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Creating a slider randomly moving increments

  • Creating a slider randomly moving increments

    Posted by Steven Probets on July 27, 2019 at 6:28 am

    I am trying to animate a slider from number ranges 0-5. It must move in whole numbers only. For example,

    12345434543212343212345432

    As you see it cannot jump from 1 to 5 for example it must move 1,2,3,4,5

    I’m not great at expressions but I can understand the code. I have looked into using wiggle and math.floor expressions but cannot get the gradual increments by whole numbers using wiggle. Keyframing the slider works but I need something better and more random.

    Thanks in advance for any help!

    Steven

    Steven Probets replied 6 years, 9 months ago 2 Members · 2 Replies
  • 2 Replies
  • Andrei Popa

    July 29, 2019 at 9:06 am

    Make a text layer. Put this in the sourceText
    var minValue = 0;
    var maxValue = 9;
    length = 50;
    seedRandom(2, timeless = true)
    initialValue = Math.round(random(0, 5));
    for(i=1;i<=length; i++){
    lastElement = parseInt(initialValue.toString().slice(-1));
    direction = (random()>0.5) ? -1 : 1;
    if (lastElement+direction > maxValue || lastElement+direction < minValue){
    direction = -direction;
    }
    initialValue +=""+(lastElement+direction)
    }

    Changing seedRandom first value creates another string(in case you dont like the one generated).

    Then, to the slider add this:
    dur = 5;
    string = thisLayer("Text")("Source Text");
    i = Math.floor(time/framesToTime(dur));
    (string.length>i) ? string[i] : value;

    Where dur is how many frames should the slider hold the value.

    Andrei
    My Envato portfolio.

  • Steven Probets

    July 29, 2019 at 10:17 am

    Thanks Andrei!

    Works great – certainly much harder as I thought. Really appreciate it.

    Steven

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy