Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Text layers to maintain distance from each other

  • Text layers to maintain distance from each other

    Posted by Iustin Filip-mucenic on April 29, 2021 at 9:28 am

    Hi all,

    I am hoping someone can figure this out for me. I have a bunch of text layers (about 20) that are all set in a line. I would like to figure out a way for them to maintain the same distance from each other even when the source text gets changed. (i have them all parented to a “control” text layer as a template). At the moment if I change the text inside they of course maintain position. I need them to be separate to be able to animate them individually which is why i can’t just have one long text layer. Thanks in advance.

    Raphaelle Brillant replied 2 weeks, 4 days ago 4 Members · 5 Replies
  • 5 Replies
  • Filip Vandueren

    April 29, 2021 at 12:25 pm

    The easiest is if you make a parent-chain, always parent the next layer to the one that should be to its left.

    Then you can give position this expression:

    sr=parent.sourceRectAtTime(time);
    [sr.left+sr.width,0]+value;

    Start by setting the position to 0,0 and then you can tweak to get the word-spacing right

  • Trent Armstrong

    April 29, 2021 at 1:17 pm

    I stand fully by the solution Filip has provided, and I will offer a secondary solution. This project has each layer referencing the position and size of the previous layer through expressions. I don’t consider it better or worse. It is just another way of accomplishing your goal. That’s what I enjoy so much about After Effects! There are—many times—multiple ways to achieve a result.

  • Filip Vandueren

    April 30, 2021 at 12:15 pm

    Here’s a third solution ;-), based on Trent’s, but also obeying the scaling of the previous layer (you mentioned you waneted to animate them, so maybe you want to scale them up and down too and have the other text-layers react):

    s = thisComp.layer("TEXT 1").effect("Padding")("Slider");
    prev = thisComp.layer(index - 1);

    w = prev.sourceRectAtTime().width;

    prev.toComp([w + s, 0]);

    (This assumes all text-layers are standard Left Aligned Text though)

  • Raphaelle Brillant

    March 22, 2024 at 2:59 am

    Hi Filip Vandueren! I’m trying to do something similar than Iustin Filip-mucenic.
    I’m pretty new to expressions so I don’t really know how to create one myself.
    Would you happen to know what the expression would be if my text layers are all set in a column instead? Also my first text layer is on the bottom and my first at the top.
    Cheers!

  • Raphaelle Brillant

    March 22, 2024 at 2:13 pm

    Update: I set up something like this tha works from top to bottom if I add multiple lines of text but can’t seem to make anything work from bottom to top. I’d like the last line of the text layer at the bottom of the comp to always stay at the same place

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy