Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Trigger comps on timeline in a random sequence

  • Trigger comps on timeline in a random sequence

    Posted by mat taylor on March 20, 2025 at 5:58 pm

    I have pre comp that contains animations playing sequentially but I would like these animations to play in a random sequence. Each animation is 5 secs long.

    If I place markers at 5 second intervals on the timeline, is there a technique that will allow the playhead to play from each marker in a random sequence?

    mat taylor replied 1 month ago 3 Members · 5 Replies
  • 5 Replies
  • Dan Ebberts

    March 20, 2025 at 6:32 pm

    Something like this time remapping expression maybe:

    dur = 5; // play each clip 5 seconds
    seed = 1103; // change this to get different result
    m = marker;
    val = time;
    if (m.numKeys > 0){
    period = Math.floor(time/dur);
    t = time%dur;
    seedRandom(seed+period,true);
    n = Math.floor(random(m.numKeys)) + 1;
    val = m.key(n).time + t;
    }
    val
  • mat taylor

    March 22, 2025 at 3:05 pm

    Thankyou, that works perfectly.

    To expand on this idea; Is it possible for the seed to change each time the comp loops around to the start again? Or each time the comp is played?

  • Dan Ebberts

    March 22, 2025 at 4:28 pm

    Actually, I don’t think you even need the markers. If you set the precomp up so it is the exact length you need to encompass however many 5-second clips you have, then time remap it in the main comp and drag the outpoint to the end of the main comp, this time remapping expression should take care of it:

    dur = 5; // play each clip for 5 seconds
    seed = 1103; // change this to get different results
    nTot = Math.floor(source.duration/dur);
    n = Math.floor(time/dur)
    seedRandom(seed+n,true);
    tStart = Math.floor(random(nTot))*dur;
    tStart + time%dur
  • Brie Clayton

    March 22, 2025 at 6:30 pm

    Thank you for solving this, Dan!

  • mat taylor

    March 27, 2025 at 4:36 pm

    Again this works perfectly. Thanks for helping me out with this one, I’ve wanted to do a project with this kind of random functionality for a long time but I do not have the skills to solve it like this!

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