Ok, this is from an old post by Filip Vandueren, it goes on Opacity. When you move the layer closer to the layer “Control” it’s opacity is controlled by the expression.
min_distance=100; // closer than this, opacity will be 100%
max_distance=10000; // from this distance, opacity will be 0%
n=this_comp.layer(“Control”); // name of your controlling layer
d=length(to_world(anchor_point), n.to_world(anchor_point));
ease(d, min_distance, max_distance, 100, 0)
If you want the falloff to be linear instead of ease, you can also change the last line to:
linear(d, min_distance, max_distance, 100, 0)
If you add sliders (Effect>Expression Controls>Slider Control) to the layer with the opacity expression and name them, “Slider Control min” and “Slider Control max”, and pickwhip to the values you get:
min_distance=effect(“Slider Control min”)(“Slider”); // closer than this, opacity will be 100%
max_distance=effect(“Slider Control max”)(“Slider”); // from this distance, opacity will be 0%
n=this_comp.layer(“Control”); // name of your controlling layer
d=length(to_world(anchor_point), n.to_world(anchor_point));
ease(d, min_distance, max_distance, 100, 0)