| Overshoot parent's rotation
on May 13, 2020 at 9:58:45 pm |
Hi everyone,
I'm trying to make the great "overshoot" expression by Dan Ebberts works with a parent layer! Let me explain :
I have 2 layers : one "Child" and one "Parent". The "Child" layer is parented to the "Parent" layer. Both move in position and rotation.
Making the position of the "Child" overshoot its own position animation and the position animation of its parent was easy, here is the expression :
freq = 3;
amp = 1;
decay = 5;
// Child position overshoot
n = 0;
if (numKeys > 0){
n = nearestKey(time).index;
if (key(n).time > time) n--;
}
if (n > 0){
t = time - key(n).time;
amplitude = velocityAtTime(key(n).time - .001)*amp;
w = freq*Math.PI*2;
childovershoot = amplitude*(Math.sin(t*w)/Math.exp(decay*t)/w);
}else
childovershoot = [0,0];
// Parent position overshoot
parentpos = thisComp.layer("Parent").transform.position;
n = 0;
if (parentpos.numKeys > 0){
n = parentpos.nearestKey(time).index;
if (parentpos.key(n).time > time) n--;
}
if (n > 0){
t = time - parentpos.key(n).time;
amplitude = parentpos.velocityAtTime(parentpos.key(n).time - .001)*amp;
w = freq*Math.PI*2;
parentovershoot = amplitude*(Math.sin(t*w)/Math.exp(decay*t)/w);
}else
parentovershoot = [0,0];
// RESULTS
value + childovershoot + parentovershoot;
Making the rotation of the "Child" overshoot its own rotation animation, easy too :
freq = 3;
amp = 1;
decay = 5;
// Child rotation overshoot
n = 0;
if (numKeys > 0){
n = nearestKey(time).index;
if (key(n).time > time) n--;
}
if (n > 0){
t = time - key(n).time;
amplitude = velocityAtTime(key(n).time - .001)*amp;
w = freq*Math.PI*2;
childovershoot = amplitude*(Math.sin(t*w)/Math.exp(decay*t)/w);
}else
childovershoot = 0;
value + childovershoot;
BUT making the rotation animation of the "Parent" layer overshoots the Child rotation is a whole other story!
I can't duplicate the Child rotation overshoot expression and make it works with the Parent rotation (like the position) because the 2 layers don't have the same anchor point, so the resulting animation won't be correct.
I'm guessing the solution would have something to do with the Child position and some trigonometry expression to convert the Parent's rotation animation into Position values taking into account the anchorpoint of the Parent. But so far, my tests gave anything useful.
Any idea?