Monday 28 January 2013

Trigger Animation at Markers


Trigger Animation at Markers

Say you have a keyframed animation that you want to
trigger at various times. All you need to do is drop a layer
marker (just press * on the numeric keypad) wherever you
want the action to be triggered. Then, apply this expression
to the animated property:
n = 0;
if (marker.numKeys > 0){
n = marker.nearestKey(time).index;
if (marker.key(n).time > time){
n--;
}
}if (n == 0){
valueAtTime(0);
}else{
t = time - marker.key(n).time;
valueAtTime(t)
}
As you can see, it’s the previous marker routine with six
new lines at the end. These lines tell After Effects to use
the property’s value from time 0 if there are no previous
markers. Otherwise, variable t is defi ned to be the time
since the most recent previous marker, and the value for
that time is used.
The result of this is that the animation will run, beginning
at frame zero, wherever there is a layer marker.

No comments:

Post a Comment