ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Trigger animation in with marker comment & out with empty marker comment

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Lionel Taurus
Trigger animation in with marker comment & out with empty marker comment
on Nov 4, 2019 at 6:28:59 pm
Last Edited By Lionel Taurus on Nov 4, 2019 at 10:21:30 pm

Hey everyone!

I'm not super use to expression but I'm trying to create a subtitle expression with custom animation in and out. The problem that I have is the following:

I want to use an empty marker comment to define the animation out of the subtitle but I can't get it to work.

Here's my file if you want to have a look at it. I'm trying to get the opacity to fadeOut when there's an empty marker, if you can help me with that, I will figure out the rest.

13868_subtitles.aep.zip

Thanks if you can help!

m = thisComp.layer("subtitles").marker;
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;
ease (time,t,t+0.2,0,100);
}else
0;




Return to posts index

Andrei Popa
Re: Trigger animation in with marker comment & out with empty marker comment
on Nov 5, 2019 at 7:06:37 am

Give this a shot. Take into consideration that this does not work well with two consecutive empty comment markers.
m = thisComp.layer("subtitles").marker;
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;
myComment = m.key(n).comment;
(myComment != "") ? ease (time,t,t+0.2,0,100) : ease (time,t,t+0.2,100,0);
}else
0;


Andrei
My Envato portfolio.


Return to posts index

Lionel Taurus
Re: Trigger animation in with marker comment & out with empty marker comment
on Nov 8, 2019 at 4:31:37 pm

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.


Return to posts index

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