Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Bounce y pos at each marker

  • Bounce y pos at each marker

    Posted by Andres Torres on September 16, 2012 at 6:37 pm

    I’m simply trying to write an expression to bounce y position at each marker. My current code produces unnatural results where the position immediately jumps at each marker.

    Thanks.

    n = 0;
    if (marker.numKeys > 0){
    n = marker.nearestKey(time).index;
    if (marker.key(n).time > time){
    n--;
    }
    }

    if (n == 0){
    value;
    } else {
    freq = 1.0; //oscillations per second
    amplitude = 90;
    decay = .5;
    t = time - marker.key(n).time;

    posCos = Math.abs(Math.cos(freq*t*2*Math.PI));
    y = amplitude*posCos/Math.exp(decay*t);
    position - [0,y]
    }

    Andres Torres replied 13 years, 10 months ago 2 Members · 2 Replies
  • 2 Replies
  • Dan Ebberts

    September 16, 2012 at 7:34 pm

    Just change Math.cos to Math.sin

    (Edit) Actually, I’d also change posCos to posSin, just so the variable name would match what it’s used for.

    Dan

  • Andres Torres

    September 16, 2012 at 8:22 pm

    Thanks Dan, you’re amazing.

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