Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Intertial Bounce Effect… but backwards?

  • Intertial Bounce Effect… but backwards?

    Posted by Brent Taylor on January 14, 2015 at 8:05 pm

    I’ve been using the inertial bounce expression from this website:

    https://www.graymachine.com/blog/my-top-expressions

    (Code Below)

    I’m trying to do the same effect, but in reverse. In other words, rather than moving and then swinging to a stop, I want it to be at rest, swing bigger and bigger, and then go.

    To see what I’m trying to do, use the code below on the rotation of an object. Put two points… one at 0 degrees and one at 90. Then just play the animation you get in reverse.

    Any idea how to do that? I feel like there should be a simple tweak I can make to the code to do it, but nothing I’ve tried so far works.

    Another step from that which would be really cool would be to be able to do both in the same animation.

    Thanks for any help.

    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
    }

    Fahd Chishty replied 11 years, 3 months ago 2 Members · 3 Replies
  • 3 Replies
  • Fahd Chishty

    January 21, 2015 at 6:13 am

    Try this.

    freq = 2;
    decay = 5;
    delay = 0.15;
    dur = 0.12;
    myDelay = delay;
    t = time - (inPoint + myDelay);
    startVal = 539 ;
    endVal = 540;
    amp = (endVal - startVal)/dur;
    w = freq*Math.PI*2;
    ans=endVal + amp*(Math.sin(t*w)*Math.exp(decay*t)/w);
    [transform.position[0], ans]


    Fahd Chishty
    Motion Design Artist
    MotionCue

  • Brent Taylor

    January 21, 2015 at 5:46 pm

    Thanks Fahd!

    That’s a good start but not quite what I’m looking for.

    The way the position’s movement starts small and then increases is great! Now we just need to apply it to the right thing…

    Right now it doesn’t respond to keyframing. Ideally it would do this between two keyframes like the inertial bounce script.

    Also, this specifically outputs Position and doesn’t work on other elements. What I want to do is affect the layer the expression is on (again like inertial bounce). I think that means affecting velocity.

    I will mess around with your version and see what I can come up with. Open to suggestions as well. Thanks again.

  • Fahd Chishty

    January 23, 2015 at 8:35 am

    To make respond to keyframes, you need to put values of startVal and endVal by keys.

    startVal = key(1);
    endVal = key(2);

    Secondly, to solve the position only problem, I replace the transform.position[0] by value[0]
    Or if you want to animate the 2nd value make it [ans, value[1]]

    freq = 2;
    decay = 5;
    delay = 0.15;
    dur = 0.12;
    myDelay = delay;
    t = time - (inPoint + myDelay);
    startVal = key(1) ;
    endVal = key(2);
    amp = (endVal - startVal)/dur;
    w = freq*Math.PI*2;
    ans=endVal + amp*(Math.sin(t*w)*Math.exp(decay*t)/w);
    [value[0], ans]


    Fahd Chishty
    Motion Design Artist
    MotionCue

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