ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Movement affecting scale

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Romain Charles
Movement affecting scale
on Jun 17, 2018 at 7:58:52 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 ?


Return to posts index

Andreas Brand
Re: Movement affecting scale
on Jun 18, 2018 at 9:44:12 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


Return to posts index

Romain Charles
Re: Movement affecting scale
on Jun 18, 2018 at 12:36:25 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.


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2018 CreativeCOW.net All Rights Reserved
[TOP]