Answers.Body: <p><a href="https://i.sstatic.net/Myigd.gif" rel="nofollow noreferrer"><img src="https://i.sstatic.net/Myigd.gif" alt="screengrab" /></a></p>
  <p>This is probably a really hacky way to do it, but you can use the &quot;sourceRectAtTime&quot; function to work out how tall or wide a layer is at any moment in time.</p>
  <p>This means even if your text layer has multiple lines in it, you can still work out where the layer below it should be positioned.</p>
  <p>So make a text layer, and call it Text 1.  Add a Slider effect to it -this will be your line height adjuster</p>
  <p>Make a text layer below it called Text 2. Add the following expression to its position:</p>
  <pre><code>height = thisComp.layer(&quot;Text 1&quot;).sourceRectAtTime().height;
  xpos = thisComp.layer(&quot;Text 1&quot;).transform.position[0];
  ypos = thisComp.layer(&quot;Text 1&quot;).transform.position[1]
  sliderval = thisComp.layer(&quot;Text 1&quot;).effect(&quot;Slider Control&quot;)(&quot;Slider&quot;);
  
  [xpos, (ypos + height) * sliderval]
  </code></pre>
  <p>Then make another text layer, call it Text 3 and add this to its position:</p>
  <pre><code>height = thisComp.layer(&quot;Text 2&quot;).sourceRectAtTime().height;
  xpos = thisComp.layer(&quot;Text 2&quot;).transform.position[0];
  ypos = thisComp.layer(&quot;Text 2&quot;).transform.position[1]
  sliderval = thisComp.layer(&quot;Text 1&quot;).effect(&quot;Slider Control&quot;)(&quot;Slider&quot;);
  
  [xpos, (ypos + height) * 1.1 * sliderval]
  </code></pre>
  <p>Where the &quot;1.1&quot; is the multiplier you want to apply to the increase in line height.</p>
  <p>Now wiggle the Slider and you should see all the layers below the first one move appropriately.  You may need to adjust the range of the slider to be quite small by right clicking on its value and choosing &quot;Edit Value&quot;</p>
  <p><a href="https://i.sstatic.net/2JdR9.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/2JdR9.png" alt="edit value" /></a></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-11-07T22:19:18.247Z
Answers.Text: Thank you @tomh ! This is the exact functionality I'm looking for, however when I replicate, something seems off about the sourceRectAtTime value for Text 1. The spacing between Text 2 and Text 3 scales proportionally, but Text 1 to Text 2 seems off. Additionally, at a 0 value on the slider, Text 2 and Text 3 both are at the exact top of the comp, which doesn't line up with your screenshots. I've attached what I'm seeing below - any help appreciated! 
  
  [https://imgur.com/a/dA5oXl0]
Answers.UserDisplayName: Pierce Wilson
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-11-07T23:36:49.417Z
Answers.Text: The value between text 1 and 2 is controlled by the height of text 1 added to its y position, then multiplied by the slider value. Try some other values to see what works - maybe a fixed numeric value added to the slider value for example.  When the slider is set to zero, all the y values will become zero (because anything multiplied by zero equals zero) , so you probably only want to start from 1 and animate the value upwards.
Answers.UserDisplayName: tomh
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-11-07T21:40:19.363Z
Answers.LastActivityDate: 2022-11-07T21:40:19.363Z
Answers.UserDisplayName: tomh
Body: <p>I have four separate text layers (each have custom expressions so must be separate instead of a single paragraph) and I wish to create a single slider control that simulates a line spacing control across all four layers as if they were all part of a single paragraph of text.</p>
  <p>I've been attempting to do this via y-value expressions which exponentially increase for each layer (as below) but this doesn't work as the amount they need to change relative to each-other is variable based on the line spacing itself.</p>
  <pre><code>First layer -&gt; value+(thisComp.layer(&quot;Null 53&quot;).effect(&quot;SPACING&quot;)(&quot;Slider&quot;))*10
  
  Second layer -&gt; value+(thisComp.layer(&quot;Null 53&quot;).effect(&quot;SPACING&quot;)(&quot;Slider&quot;))*12
  
  Third layer -&gt; value+(thisComp.layer(&quot;Null 53&quot;).effect(&quot;SPACING&quot;)(&quot;Slider&quot;))*15 
  </code></pre>
  <p>Any help with this would be fantastic - I'm fairly new to AE expressions so would love to learn from some pros!</p>
  
Tags: <after-effects-expressions>
Title: After Effects: Simulate Line Spacing Controls Across Multiple Text Layer Position Values
UserDisplayName: Pierce Wilson
ThreadText: # After Effects: Simulate Line Spacing Controls Across Multiple Text Layer Position Values
  
  (Asked by: username_0 on 2022-11-07)
  
  I have four separate text layers (each have custom expressions so must be separate instead of a single paragraph) and I wish to create a single slider control that simulates a line spacing control across all four layers as if they were all part of a single paragraph of text.
  
  I've been attempting to do this via y-value expressions which exponentially increase for each layer (as below) but this doesn't work as the amount they need to change relative to each-other is variable based on the line spacing itself.
  
  ```
  First layer -> value+(thisComp.layer("Null 53").effect("SPACING")("Slider"))*10
  
  Second layer -> value+(thisComp.layer("Null 53").effect("SPACING")("Slider"))*12
  
  Third layer -> value+(thisComp.layer("Null 53").effect("SPACING")("Slider"))*15 
  
  ```
  
  Any help with this would be fantastic - I'm fairly new to AE expressions so would love to learn from some pros!
  
  **Tags:** after-effects-expressions
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2022-11-07. Score: 0
  
  [![screengrab](https://i.sstatic.net/Myigd.gif)](https://i.sstatic.net/Myigd.gif)
  
  This is probably a really hacky way to do it, but you can use the "sourceRectAtTime" function to work out how tall or wide a layer is at any moment in time.
  
  This means even if your text layer has multiple lines in it, you can still work out where the layer below it should be positioned.
  
  So make a text layer, and call it Text 1. Add a Slider effect to it -this will be your line height adjuster
  
  Make a text layer below it called Text 2. Add the following expression to its position:
  
  ```
  height = thisComp.layer("Text 1").sourceRectAtTime().height;
  xpos = thisComp.layer("Text 1").transform.position[0];
  ypos = thisComp.layer("Text 1").transform.position[1]
  sliderval = thisComp.layer("Text 1").effect("Slider Control")("Slider");
  
  [xpos, (ypos + height) * sliderval]
  
  ```
  
  Then make another text layer, call it Text 3 and add this to its position:
  
  ```
  height = thisComp.layer("Text 2").sourceRectAtTime().height;
  xpos = thisComp.layer("Text 2").transform.position[0];
  ypos = thisComp.layer("Text 2").transform.position[1]
  sliderval = thisComp.layer("Text 1").effect("Slider Control")("Slider");
  
  [xpos, (ypos + height) * 1.1 * sliderval]
  
  ```
  
  Where the "1.1" is the multiplier you want to apply to the increase in line height.
  
  Now wiggle the Slider and you should see all the layers below the first one move appropriately. You may need to adjust the range of the slider to be quite small by right clicking on its value and choosing "Edit Value"
  
  [![edit value](https://i.sstatic.net/2JdR9.png)](https://i.sstatic.net/2JdR9.png)
  
  > **Comments:**
  > **username_0**: Thank you @username_1 ! This is the exact functionality I'm looking for, however when I replicate, something seems off about the sourceRectAtTime value for Text 1. The spacing between Text 2 and Text 3 scales proportionally, but Text 1 to Text 2 seems off. Additionally, at a 0 value on the slider, Text 2 and Text 3 both are at the exact top of the comp, which doesn't line up with your screenshots. I've attached what I'm seeing below - any help appreciated!   [https://imgur.com/a/dA5oXl0]  
  > **username_1**: The value between text 1 and 2 is controlled by the height of text 1 added to its y position, then multiplied by the slider value. Try some other values to see what works - maybe a fixed numeric value added to the slider value for example.  When the slider is set to zero, all the y values will become zero (because anything multiplied by zero equals zero) , so you probably only want to start from 1 and animate the value upwards.  
  
  ---
  
  