Skip to main content
TheYates
Known Participant
October 21, 2021
Question

Trigger animation at marker.

  • October 21, 2021
  • 2 replies
  • 238 views

Hi...

I am using this 👇 expression which takes the comment of markers and animates when the CTI hits the marker but I want to use the create a text layer with the marker's comment and when the CTI hits the marker, the same animation happen so I can have more flexibility with the text. How do I go about this?

rate = 22;
m =thisLayer.marker;
txt = "";
if (m.numKeys > 0){
n = m.nearestKey(time).index;
if (time < m.key(n).time) n--;
for (i = 1; i <= n-1; i++){
txt += m.key(i).comment + " ";
}
if (n > 0){
curWord = m.key(n).comment;
if (n < m.numKeys){
curRate = Math.max(rate,curWord.length/(m.key(n+1).time - m.key(n).time));
}else{
curRate = rate;
}
t = time - m.key(n).time;
x = curRate*t;
txt += curWord.substr(0,x);
}
}
txt

Thanks.

This topic has been closed for replies.

2 replies

Mylenium
Legend
October 22, 2021

As Roland already said, expressions cannot create anything. All you can do is read the marker comments and populate pre-existing text layers or manipulate the string generation of a text layer. Your code could liekly be expanded to simply include all markers using temporal calculations, though frankly this to me sounds like one of those attempts at "over-optimizing" an otherwise simple setup, i.e. trying to be too smart and creating a ton of convoluted expressions in place of simpler manual or script-based workflows.

 

Mylenium

Roland Kahlenberg
Legend
October 22, 2021

Expressions cannot create new assets. You need a script for such tasks. 

Very Advanced After Effects Training | Adaptive &amp; Responsive Toolkits | Intelligent Design Assets (IDAs) | MoGraph Design System DEV