Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions “Bunny Ears Wobble” expression – help needed

  • “Bunny Ears Wobble” expression – help needed

    Posted by Jason Guest on March 23, 2023 at 4:49 pm

    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;

    }

    Dan Ebberts replied 11 months, 1 week ago 2 Members · 1 Reply
  • 1 Reply
  • Dan Ebberts

    March 23, 2023 at 6:13 pm

    See if this works any better:

    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.0;
    freq = 1.0;
    decay = 1.0;
    w = freq*Math.PI*2;
    P + v*amp*Math.sin(t*w)/Math.exp(decay*t)/w;
    }else{
    P;
    }

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy