ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

add 1 to a counter whenever time passes a keyframe

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Padraic Rapp
add 1 to a counter whenever time passes a keyframe
on Mar 12, 2018 at 11:34:27 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!


Return to posts index

Dan Ebberts
Re: add 1 to a counter whenever time passes a keyframe
on Mar 12, 2018 at 5:05:58 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



Return to posts index

Padraic Rapp
Re: add 1 to a counter whenever time passes a keyframe
on Mar 13, 2018 at 8:21:38 am

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


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2018 CreativeCOW.net All Rights Reserved
[TOP]