-
Auto Center 2 Text layers that change lengths depending on language
I have a CSV file linked to text layers that change language based on a slider controller.
Depending on the language, certain words may be longer or shorter. After switching between languages, I’d love an expression to find the center of 2 different text layers, center them in the comp (on the X axis)…all while keeping their same distance from each other.
For Example:
231x More Sales is changed to 231x mehr Verkäufe. Now that the German translation is longer, the two separate text layers (231x & mehr Verkäufe) are longer in length and no longer centered on the X axis in the comp.
I’m not quite sure how to approach this. Do I tell a null’s anchor point to find the center of those two text layers and then move to the center point of the comp on the x axis?
> a = thisComp.layer(“My Layer 1”).position;
b = thisComp.layer(“My Layer 2”).position;(a + b) / 2
I know that gets me the center between two objects but does that also work for text layers? And how could I then snap that value to the center of the comp?
My thought process:
I have: Text Layer 1, Text Layer 2, Null 1 and Null 2.
1) Link Text Layer 1 and Text Layer 2 to Null 1.
2) Null 2 sits in comp center on x axis.
3) Null 1 calculates the center point between Text Layer 1 and Text Layer 2 and automatically snaps to position of Null 2.
Does that even make sense? 🤣
Thanks in advance for any help.