Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Offset keyframes randomly

  • Offset keyframes randomly

    Posted by Hannes Paulsson on September 8, 2011 at 10:13 am

    Hi!

    I have a comp with 256 different precomps (made another thread about this project a few days ago).
    All of these comps needs to rotate on the y-axis to 180 degrees. The thing is I don’t want them all to rotate at the same time, it is supposed to look random. What I have done is to animate the rotation on all of the precomps at the same time, and what I’m looking for is an expression that I could add that would offset these animations randomly by about 10 frames. I cannot offset the comps them self in time, since they all contains an animation that needs to be sync.

    I think this should be quite simple, just a short expression on the rotation value?

    Dan Ebberts replied 3 years, 2 months ago 4 Members · 5 Replies
  • 5 Replies
  • Dan Ebberts

    September 8, 2011 at 1:18 pm

    Try this:

    maxOffset = 10; // frames
    seedRandom(index,true);
    offset = framesToTime(random(maxOffset));
    valueAtTime(time-offset)

    Dan

  • Hannes Paulsson

    September 8, 2011 at 1:23 pm

    Awesome, works like a charm!

    Thanks again Dan!

  • Stuart Paciej

    April 1, 2020 at 2:03 pm

    Ancient post here but I just found it and wondered how you would make this behavior offset a loopOut expression?

    Adding it at the end just overrides the offset expression.

    maxOffset = 10; // frames
    seedRandom(index,true);
    offset = framesToTime(random(maxOffset));
    valueAtTime(time-offset);
    loopOut(“cycle”);

    Hope you see this, and thanks!

  • Francesco Rampionesi

    February 28, 2023 at 3:24 pm

    this one works very well, but if I add a loop function this one stops to works.

    How can I fix it?

  • Dan Ebberts

    February 28, 2023 at 9:04 pm

    It doesn’t work to add loopOut() to the end of another expression. You have to create your own loop functionality–something like this:

    maxOffset = 10; // frames
    seedRandom(index,true);
    offset = framesToTime(random(maxOffset));
    t = time - offset;
    if (t > key(numKeys).time){
    t = (t - key(numKeys).time)%(key(numKeys).time - key(1).time);
    valueAtTime(key(1).time + t);
    }else{
    valueAtTime(time - offset);
    }

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