Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Loop Random Velocity

  • Loop Random Velocity

    Posted by Luke Regan on April 10, 2014 at 6:11 pm

    Hi,

    I need to loop an object moving from top to bottom of the screen at random speeds/velocity.

    Let me explain further what I mean. I have two keyframes for an object’s y value. It starts on the top of the screen and ends at the bottom of the screen. Pretty simple. I then added a loopOut(“cycle”) expression so the object continually loops, moving from the top of the screen to the bottom, over and over. Perfect…

    Now what I need is for the object’s velocity or speed to randomly change each time it loops. Basically I want the time it takes the object to reach the bottom of the screen to be different every time it loops.

    How can I do this using expressions? Thanks!

    Luke Regan replied 12 years, 1 month ago 2 Members · 2 Replies
  • 2 Replies
  • Dan Ebberts

    April 10, 2014 at 6:36 pm

    This is one way. Adjust minDur and maxDur to get the range of transition times you like:


    minDur = .5;
    maxDur = 2.5;

    if (numKeys > 1){
    t = tPrev = inPoint;
    seedRandom(index,true);
    while (t <= time){
    tPrev = t;
    t += random(minDur,maxDur);
    }
    linear(time,tPrev,t,key(1).value,key(2).value);
    }else
    value

    Dan

  • Luke Regan

    April 10, 2014 at 9:53 pm

    Thanks Dan! This works perfectly.

    Any chance you could briefly explain how the code snippet works?

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