• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Creating a Mogrt: Using expression control on a keyframe

New Here ,
Oct 06, 2023 Oct 06, 2023

Copy link to clipboard

Copied

Hi,

Im fairly new to After Effects but i somehwhat know my way around it and have used expressions before to create dropdown menus in mogrts etc.

 

I'm creating a mogrt for an editor and i have a lower third animating in, it is controlled by 'position' keyframes. However, the length of the lower third will be adjusted depending on the amount of text in the box. So ideally, i would need the 2nd keyframe to be editable in length (it also needs to be capped at a specific max length so it doesnt affect the safe zone of the comp). I need this 2nd keyframe to hold for a duration of roughly 6 seconds until it animates out.

 

I think this can be done using the slider control and perhaps a null layer?

 

I would appreciate if someone could help and provide clear instructions as im fairly new to mogrts and expressions.

 

My layers below:

Screenshot 2023-10-06 at 07.56.35.png

thanks!

 

 

TOPICS
How to

Views

173

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 06, 2023 Oct 06, 2023

Copy link to clipboard

Copied

Try the forum for After Effects. 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 06, 2023 Oct 06, 2023

Copy link to clipboard

Copied

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 09, 2023 Oct 09, 2023

Copy link to clipboard

Copied

LATEST

The solution is to use sourceRecAtTime().width, and if you want to compensate for paragraph justification, add in sourceRectAtTime().left plus some padding to determine the last position of the layer.

 

The position keyframes in your screenshot are set on a nested composition, so you'll have to dig into that nested comp's text layer to determine the width. The expression would be something like this:

 

ref = comp("RECTANGLE LOWER THIRD").layer("Main Text");
b = ref.sourceRectAtTime();
pad = 100; // 100 pixel left padding, could be a slider
sp = -b.width;
ep = b.left + pad;
t= time - inPoint;
m = 30 * thisComp.frameDuration; // could be a slider to set the timing
x = easeOut(t, 0, m, sp, ep);
[x, value[1]]

 

This would eliminate the need for keyframes. You could set the timing in frames by a slider and the padding by another slider. You would get something like this:

RickGerard_0-1696920915659.gif

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines