Drag Follow
Layer follows its parent with drag and delay, like it's attached by a rubber band.
Expression Code
// Drag Follow
// Apply to Position
// Parent this layer to any moving layer
drag = 0.9; // Drag amount (0ā1, higher = more lag)
if (hasParent) {
delay = drag * 0.5; // Convert drag to time delay
samples = 10;
offset = [0, 0];
for (i = 0; i < samples; i++) {
weight = Math.pow(drag, i) / samples;
t = Math.max(0, time - i * thisComp.frameDuration);
currentParentPos = parent.toWorld(parent.anchorPoint, time);
delayedParentPos = parent.toWorld(parent.anchorPoint, t);
offset += (delayedParentPos - currentParentPos) * weight;
}
value + offset;
} else {
value;
}Parent this layer to the layer you want it to follow. Apply to Position. Adjust drag between 0 (no lag) and 1 (maximum lag) to control how loosely it follows.