React to Layer Distance
Scale, rotate, or change opacity based on distance from another layer.
Expression Code
// React to Layer Distance
// Apply to Scale, Rotation, or Opacity
// Set the target layer name below
target = thisComp.layer("Controller"); // Change to your layer name
maxDist = 500; // Maximum reaction distance
minVal = 50; // Value when far away
maxVal = 100; // Value when close
myPos = thisLayer.toWorld(anchorPoint);
targetPos = target.toWorld(target.anchorPoint);
d = length(myPos, targetPos);
t = linear(d, 0, maxDist, maxVal, minVal);
[t, t]; // For Scale ā use just t for Rotation or OpacityCreate a null or shape layer called "Controller". Apply this to Scale, Rotation, or Opacity. Move the controller around ā nearby layers react to its proximity.