The main expression i have used is this …
restLength = 70;
damp = 0.4;
leader = thisComp.layer(“leader”);
fDur = thisComp.frameDuration;
currFrame = Math.round(time / fDur);
p4 = position.valueAtTime(0);
v2 = 0;
for (f = 0; f <= currFrame; f++){
t = f*fDur;
p1 = leader.transform.position.valueAtTime(t);
delta = p4 - p1;
nDelta = normalize(delta);
a = 5 * nDelta * (length(delta) - restLength) * fDur;
v2 = (v2 - a) * damp;
p4 += v2;
}
p4
The comp consists of lots of thin vertical lines in a row. The above expression works fairly well when i move the 'leader' line left to right, the lines to its left follow with some delay and elasticity. However i want the lines that are to the right of the 'leader' line to to be repelled right as the leader gets nearer but so there is no cross over and the lines on the leaders right become more compressed together...but never touch.