Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Dan Ebbert’s Scale Bounce expression keeps breaking

  • Dan Ebbert’s Scale Bounce expression keeps breaking

    Posted by James Mccavana on May 11, 2015 at 12:18 pm

    Hello Creative Cow,

    I’ve got a problem with Dan Ebbert’s Scale Bounce expression, you know the one…

    k=16; // final scale
    a=5; // how quickly the bounce ends
    b=20; // how many bounces it’ll do (that is, the bounce speed)
    t = time-inPoint;
    x=k*(1-Math.exp(-a*t)*Math.cos(b*t));
    [x,x]

    It sometimes works, but quite frequently I get the Expression Disabled message:

    After Effects warning: Expression Disabled. Error at line 0 in property ‘Scale’
    of layer 27 (‘car’) in comp ‘Part 6’.
    invalid numeric result (divide by zero?).

    I’ve tried my best to tweak the parameters but to no avail, because I’m just guessing really. I’m wondering if it’s something to do with changing the values of a or b, which i do sometimes. But it shouldn’t break the expression if i change those values, right?

    I’d be really grateful if somebody, or even the legendary Dan Ebbert himself could fix this for me. I’ve got a ton of layers using this expression, and sometimes it works, sometimes it doesn’t.

    Many thanks in advance.

    James.

    James

    Editor / After Effects / Audio Design

    Dan Ebberts replied 11 years ago 3 Members · 4 Replies
  • 4 Replies
  • Dan Ebberts

    May 11, 2015 at 4:42 pm

    If your comp is long enough, Math.exp will eventually reach infinity. This variation should fix it:


    k=16; // final scale
    a=5; // how quickly the bounce ends
    b=20; // how many bounces it'll do (that is, the bounce speed)
    t = time-inPoint;
    if (t < 10/a){
    x=k*(1-Math.exp(-a*t)*Math.cos(b*t));
    [x,x]
    }else
    [k,k]

    Dan

  • James Mccavana

    May 11, 2015 at 5:23 pm

    Ah, Dan! You are an absolute star! Thank you so much !

    James

    Editor / After Effects / Audio Design

  • Charlotte Glasson

    May 12, 2015 at 9:17 pm

    Is there a reverse solution to this? To make items wobble back to 0%?

  • Dan Ebberts

    May 12, 2015 at 10:08 pm

    Something like this maybe:


    tOut = 10; // time to finish reverse out
    k=16; // final scale
    a=5; // how quickly the bounce ends
    b=20; // how many bounces it'll do (that is, the bounce speed)
    t = time-inPoint;

    if (t < 10/a){
    x=k*(1-Math.exp(-a*t)*Math.cos(b*t));
    [x,x]
    }else if (t < tOut - 10/a){
    [k,k];
    }else if (t < tOut){
    t = tOut - t;
    x=k*(1-Math.exp(-a*t)*Math.cos(b*t));
    [x,x]
    }else
    [0,0]

    Dan

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