Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Movement affecting scale

  • Movement affecting scale

    Posted by Romain Charles on June 17, 2018 at 7:58 pm

    Hi everybody,

    I try to use the following expression to affect scale when animating the position:

    amp = .1;
    freq = 2.0;
    decay = 2.0;
    n = 0;
    time_max = 4;
    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 < time_max){
    v = velocityAtTime(key(n).time - thisComp.frameDuration/10);
    value + v*amp*Math.sin(freq*t*2*Math.PI)/Math.exp(decay*t);
    }else{value}

    I apply this expression on an expression control position (named Bounce), and I paste on it the same animation keyframes than the position parameter.
    Then I use the following expression on the scale parameter:

    bounce=transform.position-effect("Bounce")("Point");
    value+bounce*100

    It works but I am sure that there is a simpler and better way to make the position animation affecting the size, without having to duplicate keyframes.
    Any ideas ?

    Romain Charles replied 7 years, 11 months ago 2 Members · 2 Replies
  • 2 Replies
  • Andreas Brand

    June 18, 2018 at 9:44 am

    Hi Romain

    You can directly put the following code to the scale-property.

    It uses the keys from the position-property and you don’t need an expression control property.

    amp = .1;
    freq = 2.0;
    decay = 2.0;
    n = 0;
    time_max = 4;

    keysTotal = transform.position.numKeys;
    propertyPosition = transform.position;

    if (keysTotal > 0){
    n = propertyPosition.nearestKey(time).index;
    if (propertyPosition.key(n).time > time){
    n--;
    }}
    if (n == 0){
    t = 0;
    }else{
    t = time - propertyPosition.key(n).time;
    }
    if (n > 0 && t &lt; time_max){
    v = velocityAtTime(propertyPosition.key(n).time - thisComp.frameDuration/10);
    bounce = propertyPosition.value + v*amp*Math.sin(freq*t*2*Math.PI)/Math.exp(decay*t);
    }else{
    bounce = propertyPosition.value
    }

    value+bounce*100

  • Romain Charles

    June 18, 2018 at 12:36 pm

    Thank you Andreas,

    I applied your expression on scale (using “(n > 0 && t < time_max)” instead of “(n > 0 && t < time_max)”), And the result is not what I am expecting : the scale is modified according to the velocity or speed position. But there’s no bouncing effect after.
    I had already tried to do the same thing, using “transform.position” instead of “propertyPosition.value” (is there a difference?) but didn’t work either.
    That’s why I used the second method.

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