Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions add 1 to a counter whenever time passes a keyframe

  • add 1 to a counter whenever time passes a keyframe

    Posted by Padraic Rapp on March 12, 2018 at 11:34 am

    Hello,

    I am trying to make a counter that shows the keyframe index and ticks up one whenever the current time passes a keyframe on a target layer.

    I am failing to compare the current time with the time of the next keyframe but maybe someone can help me out.

    Thank you!

    Padraic Rapp replied 8 years, 5 months ago 2 Members · 2 Replies
  • 2 Replies
  • Dan Ebberts

    March 12, 2018 at 5:05 pm

    Here’s an example that increments each time the current time reaches a position keyframe on the “target” layer:


    p = thisComp.layer("target").position;
    n = 0;
    if (p.numKeys > 0){
    n = p.nearestKey(time).index;
    if (p.key(n).time > time) n--;
    }
    n

    Dan

  • Padraic Rapp

    March 13, 2018 at 8:21 am

    yesss! Thank you so much Dan! Elegant and efficient.

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