-
Linking Opacity to Proximity
Hello,
I’m very new to After Effects and I’m coming across situations where I’m keyframing a lot of things, rather than using automatic expressions.
A situation I have now is that I want to change the opacity of an effect whenever a different object crosses over it. When the distance between the anchor points of both objects becomes 0px (perfect overlay) the opacity should be 100. When it comes close, say 50px before and 50px after, it should go to 0 again. The opacity should scale in a linear fashion from 50px to 0px to 50px of course.Is this possible, and how would I go about doing this? I found the following when searching this forum:
pivot1 = thisComp.layer(“Null 1”).transform.position;
pivot2 = thisComp.layer(“Null 2”).transform.position;
vector = pivot2 – pivot1;
vLength = Math.sqrt(vector[0]*vector[0] + vector[1]*vector[1] )
limit = 500;if(vLength > limit) {
v = 100;
} else {v = vLength /( limit/100)
}value – v;
But I have no clue if this comes close to what I need specifically.
Thanks very much.