After Effects Expression - Align Elements on a Path

This is a method that will allow you to align any element or layer to a specific path.

Full step by step Tutorial:

Paste this code into the position property of the layers you can to align:

let pathLayer = thisComp.layer("MAIN PATH");
let thePath = pathLayer.content("Shape 1").content("Path 1").path;
let sliderOffset = thisComp.layer("MAIN PATH").effect("OFFSET CONTROL")("Slider");
let offsetRepeat = sliderOffset % 100;
let offsetToAdd = linear(offsetRepeat, 0, 100, 1, 0);

let pathOffset = linear(index, 0, thisComp.numLayers-1, 0, 1);
let myPos = thePath.pointOnPath((pathOffset+offsetToAdd)%1, time);

seedRandom(index, true);
let posSlider = thisComp.layer("MAIN PATH").effect("RANDOM POSITION")("Slider");
let randomPos = random([-posSlider, -posSlider], [posSlider, posSlider]);

toComp(myPos) - thisComp.layer("MAIN PATH").transform.position + randomPos;


/*
Expression by Francisco Giordano, July 2020.
Free for personal use and commercial use.
Instagram @ae.fran.giodano - frangiordano96@gmail.com
*/

Last updated