-
valueAtTime for multiple markers
Hello,
I would like to trigger an animation multiple times for 3 layers with 3 markers.
The main animation is on the Layer “LEAD ANIMATION” and lasts 1 second.
I have 3 layers which are named A, B and C. I want to animate their opacity multiple times with the “LEAD ANIMATION” model.
And on the layer “MARKER”, there are the three markers A, B and C that repeat randomly.
I arranged this expression that allows to trigger the animation multiple times for each layer:
m = thisComp.layer(“MARKER”).marker;
animation= thisComp.layer(“LEAD ANIMATION”).transform.opacity;
tag = thisLayer.name;
nk = m.nearestKey(time);
pki = nk.index – (nk.time > time && nk.index>1 ? 1: 0);
k = m.key(pki);
if (k.comment==tag) {
animation.valueAtTime(time-k.time);
} else {
animation.valueAtTime(0);
}
The animation starts well but it stops when the next marker is reached.
I am not sure how to correct this expression to make the animation ends well even if the next marker is reached before the end of the animation.
Can you help me please?