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 layer markers > inertial bounce at each marker

  • Random motion at layer markers > inertial bounce at each marker

    Posted by Andres Torres on March 27, 2009 at 5:48 am

    Dan helped me out with this expression.

    I’d like to alter it so that instead of the random position and inertial bounce occurring at time intervals, they occur at layer markers. This would allow greater flexibility to animate to say music.

    //Dan Ebberts is my hero.
    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);

    BTW: Dan Ebberts is my hero.

    Dan Ebberts replied 17 years, 4 months ago 2 Members · 1 Reply
  • 1 Reply
  • Dan Ebberts

    March 27, 2009 at 4:04 pm

    Here’s a marker-driven version for 3D layers:

    minVal = [0.1*thisComp.width, 0.1*thisComp.height,-200];
    maxVal = [0.9*thisComp.width, 0.9*thisComp.height,1000];

    n = 0;
    if (marker.numKeys > 0){
    n = marker.nearestKey(time).index;
    if (marker.key(n).time > time){
    n–;
    }
    }
    if (n == 0){
    seedRandom(0,true);
    random(minVal,maxVal);
    }else{
    t = time – marker.key(n).time;
    seedRandom(n,true);
    p1 = random(minVal,maxVal);

    seedRandom(n-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

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