View all expressions
Transformation

Elastic Connection Expression for Linked Animation

Creates an elastic motion effect for a layer that follows another, like a spring.


// Settings
var restLength = 20;
var damp = 0.95;
var leader = thisComp.layer("leader");
// Initialize time and position
var fDur = thisComp.frameDuration;
var currTime = time;
var p2 = position.valueAtTime(0);
var v2 = 0; // Loop through each frame up to the current time
for (var t = 0; t <= currTime; t += fDur) {
var p1 = leader.transform.position.valueAtTime(t);
var delta = p2 - p1;
var dist = length(delta) - restLength;
var a = normalize(delta) * (dist * fDur * 2);
v2 = (v2 - a) * damp;
p2 += v2;
}
p2;

Elastic Connection Expression for Linked Animation

Practical use case

Perfect for animating objects connected with a spring-like motion, like bungee cords or flexible connectors.

Check out similar expressions

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

a mesh of elegant lines transparent image