Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Random motion at intervals > bounce at each interval

  • Random motion at intervals > bounce at each interval

    Posted by Andres Torres on March 26, 2009 at 2:50 pm

    I’d like to combine Dan’s expression for Random motion at intervals with the Inertial Bounce expression found below. Instead of the bounce occurring at keyframes, I want them to occur at each new Random motion interval.

    // Dan’s Random Motion at intervals expression
    holdTime = .5; //time to hold each position (seconds)
    minVal = [0.1*thisComp.width, 0.1*thisComp.height];
    maxVal = [0.9*thisComp.width, 0.9*thisComp.height];

    seed = Math.floor(time/holdTime);
    seedRandom(seed,true);
    random(minVal,maxVal)

    // Inertial Bounce (moves settle into place after bouncing around a little)
    n = 0;
    if (numKeys > 0){
    n = nearestKey(time).index;
    if (key(n).time > time){
    n–;
    }
    }
    if (n == 0){
    t = 0;
    }else{
    t = time – key(n).time;
    }

    if (n > 0){
    v = velocityAtTime(key(n).time – thisComp.frameDuration/10);
    amp = .05;
    freq = 4.0;
    decay = 2.0;
    value + v*amp*Math.sin(freq*t*2*Math.PI)/Math.exp(decay*t);
    }else{
    value;
    }

    Dustin Wilson replied 7 years, 8 months ago 3 Members · 2 Replies
  • 2 Replies
  • Dan Ebberts

    March 26, 2009 at 11:47 pm

    Something like this maybe:

    holdTime = .5; //time to hold each position (seconds)
    t = time – Math.floor(time/holdTime)*holdTime;
    minVal = [0.1*thisComp.width, 0.1*thisComp.height];
    maxVal = [0.9*thisComp.width, 0.9*thisComp.height];

    seed = Math.floor(time/holdTime);
    seedRandom(seed,true);
    p1 = random(minVal,maxVal);

    seedRandom(seed-1,true);
    p0 = random(minVal,maxVal);

    v = p1 – p0;
    amp = .05;
    freq = 4.0;
    decay = 2.0;
    p1 + v*amp*Math.sin(freq*t*2*Math.PI)/Math.exp(decay*t);

    Dan

  • Dustin Wilson

    November 16, 2018 at 5:15 pm

    Dan the man!

    Dan, I can’t thank you enough. This is exactly what I was looking to accomplish! Thank you for your time and help!

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