Skip to main content
Participant
October 25, 2021
Answered

Center align (horizontally) two text layers to comp

  • October 25, 2021
  • 1 reply
  • 1042 views

Hey all,

Looking for help on aligning two seperate text layers, both of which will be dynamic based on mograph input, to my comp's center.  In others words, I want to the two layers to be centered no matter what is typed in fields.  Any suggestions on building an expresion or script that could help me solve this?

 

 

This topic has been closed for replies.
Correct answer lenzi315

I figured it out.  If you're interested.

 

I centered the first text layer

Used sourceRectatTime to determine its width,

Offset the x position of the second text layer by one half of the first text layer's width

Parented both layers to a null object, centered in the comp

Offset the x position of the null by minus half the width of the second text layer (again using sourceRectatTime)

 

That seems to have solved my problem.

 

1 reply

lenzi315AuthorCorrect answer
Participant
October 25, 2021

I figured it out.  If you're interested.

 

I centered the first text layer

Used sourceRectatTime to determine its width,

Offset the x position of the second text layer by one half of the first text layer's width

Parented both layers to a null object, centered in the comp

Offset the x position of the null by minus half the width of the second text layer (again using sourceRectatTime)

 

That seems to have solved my problem.

 

Participant
November 8, 2023

Hey - I'm trying to build a similar setup, but I'm new to expressions. Would you be able to explain a little further or perhaps share the code you used? Please and thank you!