proximity.Scale

Expressions #001

Scripts&WorkingFiles / Youtube Motion Design Tutorials / Instagram

Enhance your animations with this distance-based scaling expression in After Effects! This expression scales a layer dynamically according to its proximity to a target layer, creating smooth, responsive motion:

// Define the target layer to determine proximity-based scaling

var targetLayer = thisComp.layer("Shape Layer 1");

// Set the minimum distance for scaling to start

var minDistance = 50;

// Set the maximum distance for scaling to end

var maxDistance = 200;

// Define the scale when near the target layer

var nearScale = [150, 150]; // Scale at minimum distance

// Define the scale when farther from the target layer

var defaultScale = [50, 50]; // Scale at maximum distance

// Calculate the distance between this layer and the target layer

var distance = length(thisLayer.position, targetLayer.position);

// Interpolate scale based on distance, between min and max values

linear(distance, minDistance, maxDistance, nearScale, defaultScale);

Using linear(), the scale interpolates between nearScale and defaultScale based on the calculated distance from the target layer, creating a seamless transition as the layers move closer or further apart. Ideal for proximity-based scaling in motion design.

Marcos Silva
Welcome to my design portfolio on Dribbble
Get in touch

More by Marcos Silva

View profile