Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions keyframe overshoot based on another layer’s movement

  • keyframe overshoot based on another layer’s movement

    Posted by Matt Howarth on October 7, 2015 at 9:46 am

    Hi all

    I’m trying to give a puppet tool pin inertial bounce when the tubby pig character moves. I was using the fantastic expression from Dan Ebbert’s moitionscript.com (again!!!, it’s a brilliant site – nice one Dan) and thought if I changed the line:

    n = nearestKey(time).index;

    to

    n =transform.position.nearestKey(time).index;

    it would work, but it tells me:
    this property has no keyframe number 2

    even though it does have two keyframes.

    I then tried driving it with a null:
    n=thisComp.layer(“Null4”).transform.position.nearestKey(time).index;

    and got the same error.

    What am I doing wrong?

    thanks

    Matt

    freq = 3;
    decay = 5;

    n = 0;
    if (numKeys > 0){
    n =transform.position.nearestKey(time).index;
    if (key(n).time > time) n--;
    }
    if (n > 0){
    t = time - key(n).time;
    amp = velocityAtTime(key(n).time - .001);
    w = freq*Math.PI*2;
    value + amp*(Math.sin(t*w)/Math.exp(decay*t)/w);
    }else
    value

    Visual tinkerer and easily distracted admirer of all things shiny! – writer – animator – digital artist

    Matt Howarth replied 10 years, 7 months ago 2 Members · 3 Replies
  • 3 Replies
  • Dan Ebberts

    October 7, 2015 at 8:05 pm

    I think it would be more like this:


    freq = 3;
    decay = 5;

    p = transform.position;

    n = 0;
    if (p.numKeys > 0){
    n =p.nearestKey(time).index;
    if (p.key(n).time > time) n--;
    }
    if (n > 0){
    t = time - p.key(n).time;
    amp = p.velocityAtTime(p.key(n).time - .001);
    w = freq*Math.PI*2;
    value + amp*(Math.sin(t*w)/Math.exp(decay*t)/w);
    }else
    value

    Dan

  • Matt Howarth

    October 8, 2015 at 8:06 am

    Dan,

    many thanks once again for taking the time to respond. You have a knack for replying with the correct response without making the person asking the question feel stupid in any way. It’s very much appreciated. : )

    I will give it a try this morning

    cheers

    Matt

    Visual tinkerer and easily distracted admirer of all things shiny! – writer – animator – digital artist

  • Matt Howarth

    October 8, 2015 at 11:01 am

    Hi Dan

    that worked an absolute treat!

    Many thanks

    Matt: )

    Visual tinkerer and easily distracted admirer of all things shiny! – writer – animator – digital artist

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