Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Wiggle + Inertial Bounce

  • Wiggle + Inertial Bounce

    Posted by Andres Torres on January 4, 2010 at 4:17 pm

    I’m trying to wiggle only the Y position property of a 3D layer AND have the “inertial bounce” expression applied.

    I’d also like to pickwhip the position of a second layer to the position of the 1st (the wiggle+inertial bounce layer) and apply the position before the inertial bounce (i.e. the original position of layer 1 before inertial bounce affects the values)

    Many thanks to the geniuses!!

    // Inertial Bounce (moves settle into place after bouncing around a little)
    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){
    v = velocityAtTime(key(n).time - thisComp.frameDuration/10);
    amp = .05;
    freq = 4.0;
    decay = 2.0;
    value + v*amp*Math.sin(freq*t*2*Math.PI)/Math.exp(decay*t);
    }else{
    value;
    }

    Benjamin Ducroz replied 16 years, 3 months ago 3 Members · 4 Replies
  • 4 Replies
  • Dan Ebberts

    January 4, 2010 at 6:37 pm

    Interesting problem. You left out some important details, so this is just a guess as to what you’re after. This expression adds a y wiggle in addition to the inertial bounce. It also “publishes” the value without the inertial bounce at negative times:

    wAmp = 100;
    wFreq = 1;
    if (time < 0){ w = wiggle(wFreq,wAmp,1,0.5,-time); [valueAtTime(-time)[0],w[1]]; }else{ w = wiggle(wFreq,wAmp); 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){
    v = velocityAtTime(key(n).time – thisComp.frameDuration/10);
    amp = .05;
    freq = 4.0;
    decay = 2.0;
    [value[0],w[1]] + v*amp*Math.sin(freq*t*2*Math.PI)/Math.exp(decay*t);
    }else{
    [value[0],w[1]];
    }
    }

    If you want another layer to follow the non-inertial-bounce motion of the original layer, you’d use an expression like this:

    thisComp.layer(“Black Solid 1”).transform.position.valueAtTime(-time)

    I hope that’s close to what you were after.

    Dan

  • Benjamin Ducroz

    April 17, 2010 at 7:37 am

    this is a really handy script for the job i’m working on.
    i can’t find the co-ordinates in this.
    how can i make it wIggle on both X & Y?

  • Dan Ebberts

    April 17, 2010 at 2:11 pm

    Try changing the last part of the expression to this:

    [w[0],w[1],value[2]] + v*amp*Math.sin(freq*t*2*Math.PI)/Math.exp(decay*t);
    }else{
    [w[0],w[1],value[2]];
    }
    }

    Dan

  • Benjamin Ducroz

    April 18, 2010 at 12:22 am

    Thank you Dan, much appreciated!
    it did not work at first, but I got the error

    Class ‘Array’ has no property or method named ‘2’.

    I tried replacing the 2 with 1 and this worked.
    So the full working script is as follows:

    i’ve used this expression on puppet pins. and it works really well for what i’m doing.

    really appreciate the help, thanks again!

    wAmp = 100;
    wFreq = 1;
    if (time < 0){
    w = wiggle(thisComp.layer("WIGGLE").effect("wiggle_amount")("Slider"),thisComp.layer("WIGGLE").effect("wiggle_rate")("Slider"),1,1,-time);
    [valueAtTime(-time)[0],w[1]];
    }else{
    w = wiggle(thisComp.layer("WIGGLE").effect("wiggle_amount")("Slider"),thisComp.layer("WIGGLE").effect("wiggle_rate")("Slider"));
    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){
    v = velocityAtTime(key(n).time - thisComp.frameDuration/10);
    amp = .05;
    freq = 4.0;
    decay = 2.0;
    [w[0],w[1],value[1]] + v*amp*Math.sin(freq*t*2*Math.PI)/Math.exp(decay*t);
    }else{
    [w[0],w[1],value[1]];
    }
    }

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