View all expressions
Interpolation

Distance Between Two Layers Expression

Finds the straight-line distance (in pixels) between this layer and a target layer and outputs that number.

Contributed by:


target = thisComp.layer("Target Layer");
// pick your target layer
p1 = position;
p2 = target.position;
length(p1, p2);

Distance Between Two Layers Expression

Practical use case

Drive effects like blur, opacity or scale based on how close two layers are - perfect for reactive HUDs or infographics.

Check out similar expressions

Data-driven video workflows for After Effects are easier with Plainly.

a mesh of elegant lines transparent image