ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

# Constant expression to non constant expression

FAQ   •   VIEW ALL
 Constant expression to non constant expression on Aug 17, 2012 at 6:41:53 pm

That's probably a complicated way of explaining it.

Basically I have some cogs which I have used expressions to make them move all using the main cog as a reference (so if they client wants it longer, it's easy to amend).

Later in the animation I want to slow and eventually stop the cogs, then they fall off. How do I do this? At the moment the main cog has 'time*150 on the Z axis.

Thanks

Olly Lawer

 Re: Constant expression to non constant expressionon Aug 17, 2012 at 7:34:45 pm

This is one of those speed-control things that turns out to be trickier than it seems like it should be. Although it doesn't address this case exactly, this article has some good background info on calculating the "area under the curve", which is what you need in this case:

http://www.motionscript.com/articles/speed-control.html

This expression does that--it will begin to slow down at 6 seconds, and will slow to a stop over a one-second period:

``` rate = 150; beginStop = 6; stopDur = 1; if (time < beginStop){ time*rate; }else if (time < beginStop + stopDur){ r = linear(time,beginStop,beginStop + stopDur,rate,0); (beginStop + stopDur/2)*rate - (beginStop+stopDur - time)*r/2; }else{ rate*(beginStop + stopDur/2); } ```

Dan

 Re: Constant expression to non constant expressionon Aug 17, 2012 at 7:35:48 pm

Thanks Dan tho that just fried my brain. Is there an easy way to do it with an expression control maybe?

Olly Lawer

 Re: Constant expression to non constant expressionon Aug 17, 2012 at 8:04:32 pm

Well, you could add a Slider Control to the layer, set a keyframe for 150 at 6 seconds and another for 0 at 7 seconds, then apply the Rotation expression in this section of the article:

http://www.motionscript.com/articles/speed-control.html#linear

It should give you the same result as the previous expression.

Dan