-
Rope-ish Dynamics Expression
Hello folks!
I’m applying this expression to the position property of 10 nulls.
P = thisComp.layer("leader").position;
delay = thisComp.layer("leader").effect("delay")("Slider"); // link to a slider for easy tweaking
de = delay*thisComp.frameDuration*(index-thisComp.layer("leader").index);
F = thisComp.layer(index-1).position.valueAtTime(time-de);
xyz = position.valueAtTime(0) - thisComp.layer(index-1).position.valueAtTime(0);
n = 0;
if (P.numKeys > 0){
n = P.nearestKey(time).index;
if (P.key(n).time > time){
n--;
}
}
if (n == 0){
t = 0;
}else{
t = time - P.key(n).time;
}
if (n > 0){
v = P.velocityAtTime(P.key(n).time - thisComp.frameDuration/10);
amp = thisComp.layer("leader").effect("amp")("Slider") // link to a slider for easy tweaking
freq = thisComp.layer("leader").effect("freq")("Slider"); // link to a slider for easy tweaking
decay = thisComp.layer("leader").effect("decay")("Slider") // link to a slider for easy tweaking
F + v*amp*Math.sin(freq*t*2*Math.PI)/Math.exp(decay*t) + xyz;
}else{
F + xyz;
}I’m getting close to what I’m looking for, which is similar to the dynamic of a rope.
My issue is with what happens to the nulls after the final keyframe of the leader layer.
Everything works properly until the animation reaches the last keyframe, at which point the expression appears to stop the inertia movement.It is difficult to explain, but I have attached an image of the mofraph to help you understand.
Can someone help me with this?:D