Thank you so much for helping Andrei! I tried to understand your piece of code and came up with a solution that seems to work for me ☺!
So for those looking for a similar thing for subtitles, here’s what I did:
I have 2 layers in my composition, one is an empty text layer and the other a null Object called “subtitles” where I used markers with comments to write the subtitles.
On the Source Text property of my text layer I have this expression :
m = thisComp.layer("subtitles").marker;
if (m.numKeys > 0){
n = m.nearestKey(time).index;
if (time < m.key(n).time) n--;
if (n > 0) {
txt = m.key(n).comment;
if (txt == "") {
txt = m.key(n-1).comment
}else txt;
}
}
and on the opacity this:
m = thisComp.layer("subtitles").marker;
delay=0.5;
n = 0;
if (m.numKeys > 0){
n = m.nearestKey(time).index;
if (m.key(n).time > time) n--;
}
if (n > 0){
t = m.key(n).time;
hello = m.key(n).comment;
if (hello == "") {
ease (time,t,t+0.3,100,0);
} else {
ease (time,t,t+0.2,0,100);
}
}
You can get fancy and add other animations using the same piece of code that I used for the opacity anywhere you want (don’t forget to change the values depending of what you want to animate). You can also change the type of ease to easeOut or easeIn.