ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

# Change layer opacity once it reaches position

FAQ   •   VIEW ALL
 Change layer opacity once it reaches position on Apr 26, 2019 at 1:45:06 pm

I am just starting the learning process for expressions and I'm at the level where I can usually find one that works for what I need and then tweak it accordingly ( unless it's super complex). However, I still haven't fully grasped how to effectively write expressions from scratch.

I am creating a stream of particles individually with the help of expressions (because that's how I got the control I needed) and now I would like to have each layer's opacity fade out once it reaches a position. An expression to fade in and out at the in and outpoint didn't work because each particle is reaching the end location at a different time. So, I need an expression that changes the opacity on layer A once it reaches a designated position. I may be overthinking it but thanks in advance!

 Re: Change layer opacity once it reaches positionon Apr 27, 2019 at 7:10:36 am

Linear() is a good expression for such things. What it does is remaps an input range of a variable to an output range. So, you can give it the variable X (which can literally be the x coordinate of the layer, for instance) and tell which input range, say 1000 to 1500 you want to convert to what output range. Since opacity goes from 0 to 100 you can therefore convert it to 100 to 0 for an opacity fade. The resulting expression goes:

linear(X, 1000, 1500, 100, 0)

and would be applied to the opacity of the layer. Since X is not yet defined there, you would pick-whip it to the property you want, such as the x coordinate of the layer position. Or you could calculate the distance from a given point for the value of X with a bit of trigonometry.

The input value range can be whatever you want so as to make it fade within the X range you want.

Kalleheikki Kannisto
Senior Graphic Designer

 Re: Change layer opacity once it reaches positionon Apr 27, 2019 at 10:55:54 am

If you prefer an expression-free solution, you can precomp all your particle layers and use a track matte with a gradient ramp to make them fade out where you want.

Kalleheikki Kannisto
Senior Graphic Designer