Fire action on every keyframe
I want drive change of effect property on every keyframe: it would change its value from 0 to 1 and vice versa (basically on & off).
So far I have this expression for the effect "Dust & Scratches" sitting on its "Threshold" property:
var v = 1;
var n = timeRemap.numKeys;
if (n > 0){
if(time < timeRemap.nearestKey(time).time){
if(v == 0){
v = 1;
}else{
v = 0
}
}
}
v
Problem is I would like to be able fire the change exactly on every new keyframe but I am not able to get there, this is the closest but of course it changes the value "erratically" once it reaches middle point between two frames.
I tried also this but to no success too as the variables kfA/kfB are initialized with every frame 😞
var kfA = 1;
var kfB = 2;
var v = 1;
var n = timeRemap.numKeys;
if (n > 0){
if(time >= timeRemap.key(kfA).time && time < timeRemap.key(kfB).time){
if(v == 0){
v = 1;
}else{
v = 0
}
}
if(time == timeRemap.key(kfB).time){
kfA++;
kfB++;
}
}
v