Skip to main content
Known Participant
June 20, 2024
Question

How can I attach multiple objects to a moving path?

  • June 20, 2024
  • 3 replies
  • 2114 views

I'd like to attach all of these shapes to this moving white line. Any help would be appreciated! The green one you see attached I did with Trace Paths. But it doesn't work for multiple objects. Thank you in advance.  

This topic has been closed for replies.

3 replies

Dan Ebberts
Community Expert
Community Expert
June 20, 2024

If you have a shape layer with a path and a bunch of other consecutive layers that you want to distribute along the path, you can use a position expression like this, where you set firstLayerIndex to the layer index of the first layer to be distributed and lastLayerIndex to the layer index of the last layer to be distributed:

 

L = thisComp.layer("Shape Layer 1");
p = L.content("Shape 1").content("Path 1").path;
firstLayerIndex = 1;
lastLayerIndex = 5;
myPct = (index - firstLayerIndex)/(lastLayerIndex - firstLayerIndex);
L.toComp(p.pointOnPath(myPct))

 

JudieLAuthor
Known Participant
June 20, 2024

Hi Dan, I've applied the code you suggested but it's not connecting. Can you please let me know where I've gone wrong in this screen shot? Thank you.

Dan Ebberts
Community Expert
Community Expert
June 20, 2024

There's an extra line at the top of your expression that shouldn't be there. It looks like firstLayerIndex should be set to 3 (?). If there's only one layer getting distributed then I guess lastLayerIndex should also be set to 3. Where is the path exactly (maybe post another screen shot that shows the stroke layer twirled open to expose the path)? Also, the layers being distributed shouldn't be parented to anything.

Roland Kahlenberg
Legend
June 20, 2024

This tutorial has your solution - https://youtu.be/4-VCqLDDcNg

HTH


Very Advanced After Effects Training | Adaptive & Responsive Toolkits | Intelligent Design Assets (IDAs) | MoGraph Design System DEV
JudieLAuthor
Known Participant
June 20, 2024

Hi Roland, Thank you for sending. I saw this before posting. It's for repeating one asset. I need to add multiple. If you have any suggestions for multiple objects on the same animated path that would be super. Thank you.

Roland Kahlenberg
Legend
June 20, 2024

I've not watched the entire video but my thoughts are that with different layers and not just duplicated layers, the distrbution should still work. You have to ensure each layer has the required Expression. 

What issue(s) did you face when trying out the technique?


Very Advanced After Effects Training | Adaptive & Responsive Toolkits | Intelligent Design Assets (IDAs) | MoGraph Design System DEV
Community Expert
June 20, 2024

If I'm understanding what you want to do correctly you could create a null object, parent the objects to the null and then copy and paste positioning from the path into positioning on the null object

JudieLAuthor
Known Participant
June 20, 2024

Hi Rob, What is the "pat"? Thank you.

JudieLAuthor
Known Participant
June 20, 2024

Just realized you meant "path", my apologies. In theory, what you suggested would work. But when I copy the path key frames into the Null position, it goes bonkers like this. Even the keyframes paste all bunched up.