FORUMS: list search recent posts

# Animating a property over a specified time

FAQ   •   VIEW ALL
 Animating a property over a specified time on Apr 15, 2013 at 2:54:57 pm

Hi!

I wasn't able to find anything here or on google, but this should be really basic and easy... Maybe you could help!

I have a lot of pitures (3d) in a comp which are not animated on their own. A camera moves backwards and the pics with different z-values "fly away". All I want to accomplish is that when a picture reaches a certain distance to the camera, it should begin scaling down to 0 over a certain amount of time, let's say 2 sec.

The expression I've got right now is this one:

startScale = [100, 100, 100];
endScale = [0, 0, 0];
distance = thisComp.layer("Camera 1").transform.position[2] - transform.position[2];

if (distance > (-12000))
{startScale}
else
{ease (time, in_point, out_point, startScale, endScale)}

Works, but 2 problems: Now the scale-value stays at 100% as it should but when the layer reaches the specified distance to the cam it jumps to the value which it has at this point in time! I want it to smoothly scale down from 100 to 0!
Second is that I don't want to use the layer in- and out-points as tMin / tMax. tMin should be the frame where the specified distance is reached (how do I convert that in time??) and tMax 2 sec later!

 Re: Animating a property over a specified timeon Apr 15, 2013 at 3:54:55 pm

Distance triggers aren'e simple. You have to go through the timeline, frame by frame, to find out how long it has been since the threshold was reached.

Something like this:

``` startScale = [100,100,100]; endScale = [0,0,0]; threshold = 12000; p2 = thisComp.layer("Camera 1").transform.position; p1 = transform.position; fCur = timeToFrames(time); f0 = timeToFrames(inPoint); t = inPoint; for(i = f0; i <= fCur; i++){ t = framesToTime(i); if (Math.abs(p1.valueAtTime(t)[2] - p2.valueAtTime(t)[2]) > threshold) break; } ease(time-t,0,2,startScale,endScale) ```

Dan