Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Randomize slider every 30 frames

  • Randomize slider every 30 frames

    Posted by Nihad Spahic on March 6, 2022 at 7:42 pm

    Hey guys, I am really stuck on this one. So I have 6 layers in the composition, 5 graphics, and one Settings layer. There is a slider control on the settings layer with rounded options from 1 to 5 with expression Math.floor(clamp(value, min=1, max=5))

    Each graphic is related to the slider on the settings layer with expression

    v = thisComp.layer(“Settings”).effect(“Select Version (1-5)”)(1);

    if (v==index-1) {100} else {0}

    so I can control visibility with slider from first to fifth element.

    I would love to randomize order on the slider, to change from 1 to 5 every 30 frames, and also to control it with the checkbox, so I could choose if I want only one layer to be shown or to randomize visibility every 30 frames.

    Cheers!

    Nihad Spahic replied 4 years, 5 months ago 2 Members · 2 Replies
  • 2 Replies
  • Filip Vandueren

    March 6, 2022 at 10:39 pm

    Hello Nihad,

    maybe something like this: (expression on the slider controller)

    seedRandom(index,true);

    values=[1,2,3,4,5];

    if (effect("Random")("Checkbox").value == true) {

    i=0;

    t=timeToFrames(time/30); // change every 30 frames

    // get non repeating random numbers

    for (j=0; j<t; j++) {

    i+=1+Math.floor(random(values.length-1));

    }

    output = values[i%values.length];

    } else {

    output = Math.floor(clamp(value, min=1, max=5));

    }

    output;

  • Nihad Spahic

    March 7, 2022 at 12:11 pm

    Hey Filip,

    works like a charm! Thank you so much, exactly what I needed.

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