1

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!

1 Answer 1

0

screengrab

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

2
  • 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! [imgur.com/a/dA5oXl0] Nov 7, 2022 at 22:19
  • 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.
    – tomh
    Nov 7, 2022 at 23:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.