top of page

Proximity Expression

This expression scales a layer dynamically based on its proximity to a target, controlled via sliders for maximum scale and range.

Background Line UI

Dynamic, Transform, Time Based Animation

3.4K

// Define the target and controller layers
target = thisComp.layer("Target");
controller = thisComp.layer("Controller");

// Get the maximum scale and range values from the controller
maxScale = controller.effect("Max Scale")("Slider");
range = controller.effect("Range")("Slider");

// Calculate the distance between the target and the current layer
dist = length(target.position, position);

// Smoothly interpolate the scale factor based on the distance
scaleFactor = ease(dist, 0, range, maxScale, 100);

// Return the scale value for both X and Y axes
[scaleFactor, scaleFactor];
This expression scales a layer dynamically based on its proximity to a target. For example, create a null named "Target" and another null named "Controller" with two sliders: Max Scale and Range. Apply the expression to a shape layer’s Scale property, and adjust the sliders to see the shape react to the target’s distance.
bottom of page