-
“Bunny Ears Wobble” expression – help needed
Hello! It’s been many years since I last posted on here.
I’d like help with an expression I wrote years ago, I actually cobbled it together from a couple of expressions I found online, and miraculously it worked – almost!
What it does: It inherits the rotation from the parent layer and uses it to create a wobble. I’ve used it many times for the ears and antennae of cartoon characters so that when they move their heads, their ears give a little wobble. You can also use it in a sequence of parented layers to make chains, which is what I plan to use it for today.
What is wrong with it: What seems to be happening is that the parented layer inherits the rotation from the parent exactly until the second keyframe of the movement and then goes into the wobble, which creates a noticeable little kick of acceleration. I’ve got around this problem in the past by putting slow-ins and slow-outs on the keyframes and increasing the amplitude.
What I’d like to know: Can this expression be fixed, or is there another one I can use which does the same thing but better?
Code below:
// Bunny Ears Wobble 1.0.0
P = parent.rotation;
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 = 1.5;
freq = 1.0;
decay = 0.25;
P + v*amp*Math.sin(freq*t*2*Math.PI)/Math.exp(decay*t);
}else{
P;
}