After Effects Tutorial – Even Layer Spacing
If you want layers evenly spaced in a composition, there’s a handy expression for that.
First, create a position expression and make a variable. The variable is going to equal the index of the layer, and then be divided by the number of layers in the composition plus one. This gives a value between 0 and 1, because the index must at least be 1. Then, all of this is multiplied by the width of the composition. This gives a result that is between 0 and the width of the composition. This equation scales with additional layers, thus keeping even spacing between them.
var spacing = thisLayer.index/(thisComp.numLayers+1)*thisComp.width;
Since this is position, the value must be returned as an array. So, if you want to use the variable for the X position, then include the variable name there and use the unchanged Y position.
This should all be done in a separate composition because the equation reads the index value. This is because if you add an additional layer in the composition on top of these layers, it will alter the positioning of the layers.
Enjoying this tutorial? Sign up for the Creative COW Newsletter!
Sign up for the Creative COW newsletter and get weekly updates on industry news, forum highlights, jobs, inspirational tutorials, tips, burning questions, and more! Receive bulletins from the largest, longest-running community dedicated to supporting professionals working in film, video, and audio.
Enter your email address, and your first and last name below!