0

I'm working on a video comparing old and new games, and I'm scrubbing through some footage frame by frame trying to count button inputs in DOOM over a period of time. I was wondering if there was a way to increment a number based on the amount of keyframes present. So ideally it would automatically go up by one for each keyframe placed on the timeline, without having to manually increase the value on a per keyframe basis. Is there an easy way to go about this or will I have to manually set the value per keyframe?

I've never really used expressions before so this is new territory for me, and I don't know where to start.

Thank you.

1 Answer 1

1

Yep, just do

var p = <pick whip the property with the keyframes here>;
var k = p.nearestKey(time);
if (k.time <= time){
    k.index; //key is in the past
} else {
    k.index-1; //nearest key is in the future, return the previous key
}

On the first line you have to reference the property with the keyframes. The easiest way is with the pick whip (the curly thing in the expressions buttons). Drag it to the property you want to reference.

enter image description here

So the first line should look something like this:

var p = thisComp.layer("Pale Gray-Magenta Solid 2").effect("Slider Control")("Slider");

or

var p = transform.position;

Don't forget the semi-colon at the end.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.