Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity › Forums › Adobe After Effects Expressions › Adding Anticipation, Overshoot, Bounce with dropdown menu

  • Adding Anticipation, Overshoot, Bounce with dropdown menu

    Posted by Dominique Parisi on May 7, 2020 at 12:38 pm

    Hi !

    I have been playing around with this script Dan wrote earlier this years, but I’m trying to add “””functionalities””” to it.

    As a reel thickheaded at coding, I’m turning to you guy’s for a bit of enlightenment

    Already have I played with this, adding a dropdown menu allowing me to switch between linear, ease, ease in, ease out. (only put the linear part of the code)

    I would like to add the possibility to have a anticipation before the animation or overshoot bounce, after the animation.

    I have stumble upon “inertial bounce” and “bounce back” expression from Dan , tried to play with them but had unforeseen mishap. (like jumping to the end position value without smooth mouvement. )

    Could it be possible to blend those expression to be able to switch between the animation type with a dropdown menu ?

    Thx to anyone who answer ( even “no it’s not” ???? )

    //moveAmt is defined by the length of another composition
    // Starpos is defined by a slider control in a "control-comp"

    if (dropMenu == 1) {
    if (m.numKeys > 0) {
    n = m.nearestKey(time).index;
    if (time < m.key(n).time) n--;
    accum = 0;

    y = 0;
    if (n > 0){
    if ( n > 1){
    for (i = 1; i < n; i++){
    if (m.key(i).comment == "Move") accum += moveAmt
    }
    }
    if (m.key(n).comment == "Move"){
    t = time - m.key(n).time;
    y = linear(t,0,m.key(n).duration,0,moveAmt);

    }
    val = value + y + accum + StarPos ;
    }
    }

    val
    }

    Victor Nash replied 1 day, 7 hours ago 2 Members · 1 Reply
  • 1 Reply
  • Victor Nash

    September 27, 2026 at 3:53 pm

    This is an old post, but while I was researching building an expression with Anticipation with Inertial Bounce I saw this. I did work on building out an expression (not a dropdown), so I hope this helps anyone looking. works on 2D, 3D

    // RUBBER-BAND ANTICIPATION + INERTIAL BOUNCE

    // =========================

    // ANTICIPATION

    // =========================

    anticipationAmount = 30;

    anticipationTime = 0.20;

    anticipationPull = 1;

    // =========================

    // BOUNCE

    // =========================

    bounceAmount = 50;

    bounceSpeed = 3;

    bounceFreq = .8;

    bounceDecay = 4;

    if (numKeys < 2){

    value;

    }else{

    k = nearestKey(time).index;

    if (key(k).time > time) k–;

    k = Math.max(1, Math.min(k, numKeys – 1));

    t1 = key(k).time;

    t2 = key(k + 1).time;

    p1 = key(k).value;

    p2 = key(k + 1).value;

    // PATH DIRECTION

    path = p2 – p1;

    dist = length(path);

    if (dist > 0){

    dir = path / dist;

    }else{

    dir = p2 – p2;

    }

    // ANTICIPATION

    ant = Math.min(

    anticipationTime,

    (t2 – t1) * 0.4

    );

    antEnd = t1 + ant;

    if (time < t1){

    p1;

    }else if (time < antEnd){

    // Pull backward quickly

    u = (time – t1) / ant;

    pull = 1 – Math.pow(

    1 – u,

    anticipationPull

    );

    p1 – dir * anticipationAmount * pull;

    }else if (time < t2){

    // Accelerate INTO the second keyframe.

    // No ease-out at the destination.

    u = (time – antEnd) / (t2 – antEnd);

    startPos = p1 – dir * anticipationAmount;

    forwardDist = dist + anticipationAmount;

    baseSpeed = dist / (t2 – t1);

    s = baseSpeed * (t2 – antEnd) / forwardDist;

    s = Math.max(0, Math.min(3, s));

    // Starts gently, accelerates,

    // and arrives at full speed.

    f = (s – 2) * u * u * u

    + (3 – s) * u * u;

    startPos + (p2 – startPos) * f;

    }else{

    // INERTIAL BOUNCE

    elapsed = time – t2;

    bounce =

    Math.sin(

    elapsed *

    bounceSpeed *

    bounceFreq *

    Math.PI * 2

    ) *

    Math.exp(

    -bounceDecay * elapsed

    );

    p2 + dir * bounceAmount * bounce;

    }

    }

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