ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Using a marker with specific name to trigger animation multiple times

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Andrew Millen
Using a marker with specific name to trigger animation multiple times
on Mar 14, 2019 at 2:03:11 am
Last Edited By Andrew Millen on Mar 14, 2019 at 2:26:32 am

I've got two markers on a shape layer each called "Click." I use this expression to animate the scale:



rampStart = marker.key("Click").time;
rampEnd = marker.key("Click").time + .15;
startVal = [100,100];
maxVal = [85,85];

rampMid = rampStart + (rampEnd - rampStart)/2;
if (time < rampStart || time > rampEnd){
value
}else if (time < rampMid){
ease(time,rampStart,rampMid,startVal, maxVal)
}else{
ease(time,rampMid,rampEnd,maxVal,startVal)
}


Using the code found here, I want to replace the "wobble" effect with my own scale expression above AND have it specify the marker by name, not just any marker on the layer.


n = 0;
t = 0;
if (marker.numKeys > 0){
n = marker.nearestKey(time).index;
if (marker.key(n).time > time) n--;
}
if (n > 0) t = time - marker.key(n).time;

amp = 15;
freq = 5;
decay = 3.0;

angle = freq * 2 * Math.PI * t;
scaleFact = (100 + amp * Math.sin(angle) / Math.exp(decay * t)) / 100;
[value[0] * scaleFact, value[1] / scaleFact];


But I'm not conversant enough in expressions to make it happen. Can anyone help? I'm sure it's super obvious to someone who knows what they're doing.


Return to posts index

Oleg Pirogov
Re: Using a marker with specific name to trigger animation multiple times
on Mar 14, 2019 at 4:38:43 am

I suppose you only need to add a line that checks, if the comment of nearest (from the left) marker equals "Click":

theMarker = marker.key("Click");

n = marker.nearestKey(time).index;
if (marker.key(n).time > time) n--;
if (n!== 0 && marker.key(n).comment == "Click") theMarker=marker.key(n);

rampStart = theMarker.time;
rampEnd = theMarker.time + .15;
startVal = [100,100];
maxVal = [85,85];

rampMid = rampStart + (rampEnd - rampStart)/2;
if (time < rampStart || time > rampEnd){
value
}else if (time < rampMid){
ease(time,rampStart,rampMid,startVal, maxVal)
}else{
ease(time,rampMid,rampEnd,maxVal,startVal)
}


P.S. I've omitted marker.numKeys > 0 condition since your code assumes there's at least one marker anyway.
And if there are several markers with the same comment (a.k.a key(name)) "Click", this: marker.key("Click") - returns the first of them


Return to posts index

Andrew Millen
Re: Using a marker with specific name to trigger animation multiple times
on Mar 15, 2019 at 2:21:08 am

That did it, thanks!


Return to posts index

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