Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Decoding Bounce Expression

  • Decoding Bounce Expression

    Posted by Ian Brown on February 10, 2022 at 3:47 pm

    Hello, can someone help me understand this expression at a high level, if you’ve the patience then by line would be helpful, but the last 3 lines (else statement) are most key

    amp = .1;
    freq = 2.0;
    decay = 2.0;
    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 && t < 1){
    v = velocityAtTime(key(n).time - thisComp.frameDuration/10);
    value + v*amp*Math.sin(freq*t*2*Math.PI)/Math.exp(decay*t);
    }else{value}amp = .1;
    freq = 2.0;
    decay = 2.0;
    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 && t < 1){
    v = velocityAtTime(key(n).time - thisComp.frameDuration/10);
    value + v*amp*Math.sin(freq*t*2*Math.PI)/Math.exp(decay*t);
    }else{value}
    Ian Brown replied 4 years, 3 months ago 2 Members · 2 Replies
  • 2 Replies
  • Dan Ebberts

    February 10, 2022 at 7:16 pm

    It looks like you pasted it in twice, but in any case, the expression looks for the most recent, previous keyframe, calculates the velocity coming into that keyframe, and uses that velocity to calculate a decaying sine wave oscillation that gets added to the current value. The oscillation gets get off abruptly after 1 second.

  • Ian Brown

    February 10, 2022 at 10:13 pm

    Apologies, yes I did.

    Thanks!

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