ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

How do I pull the TIME of the First keyframe from a layer?

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Jonathan Moxness
How do I pull the TIME of the First keyframe from a layer?
on Jul 18, 2017 at 9:00:48 pm
Last Edited By Jonathan Moxness on Jul 19, 2017 at 8:45:07 pm

I'm creating a fighting-game style health-bar element that moves based on keyframes (input manually) of a Null Slider Control layer. What I want is when said Main Bar moves, a Red Health Bar layer behind it remains stationary for about 30 frames, then fades out to 0 opacity. Then the next time the Main Bar moves, the Red Health Bar (or a duplicate Red Health Bar) is at the Main Bar's previous position, remains stationary for about 30 frames, then fades out to 0 opacity, etc. etc.
I've figured out how to get the Red Health Bar's opacity keyframes to start in time with the last keyframe of the Slider Control layer using this expression:

kf = comp("Working Comp").layer("Right Health Bar").effect("Slider Control")("Slider");
tm = kf.key(kf.numKeys).time;
opacity.valueAtTime(time - tm);

But I don't know how to time it with the FIRST keyframe. If I can get that, I figured I could just add an index expression so it goes up incrementally.


Here's an example from Street Fighter V of what I'm trying to emulate:





Thanks in advance for any help!


Return to posts index

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