Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
2

Animate multiple Objects along with a path without adding keyframe

Community Beginner ,
Mar 28, 2024 Mar 28, 2024

Hi,
I am planning to create an animation in which several shapes such as circles, rectangles, and triangles move along a particular path. I want the shapes to follow the path automatically whenever I move the path of the shape layer, without having to add a keyframe manually. This is different from an orient path.
I'm expecting your valuable suggestions on this, Thanks !!
animation
Referenceexpand image

TOPICS
Error or problem , Expressions , FAQ , How to , Scripting
968
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Advocate , Mar 29, 2024 Mar 29, 2024

Try this expression and offset the work area start

d = parent.effect("duration")("Slider");
o = parent.effect("offset")("Slider");
s = framesToTime(o * (index - 1));
e = s + d;
parent.content("Shape 1").content("Path 1").path.pointOnPath(linear((time - s) % (e - s), 0, d, 0, 1))

 screenshot.pngexpand image

 

Translate
Advocate ,
Mar 28, 2024 Mar 28, 2024

You can parent your shape layers to the path layer.

Add two slider controls (offset, duration) on the path layer

and apply this position expression to your shape layers:

 

d = parent.effect("duration")("Slider");
o = parent.effect("offset")("Slider");
s = o * (index-1);
e = s + d;
parent.content("Shape 1").content("Path 1").path.pointOnPath(linear(time, s, e, 0, 1))

 

screenshot.pngexpand image

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Mar 29, 2024 Mar 29, 2024

Thanks much !!@Airweb_AE This will help me, but I still have doubts about how to turn it into a loop
Thanks again for your effort !!

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Mar 29, 2024 Mar 29, 2024

Try this:

d = parent.effect("duration")("Slider");
o = parent.effect("offset")("Slider");
s = framesToTime(o * (index - 1));
e = s + d;
parent.content("Shape 1").content("Path 1").path.pointOnPath(linear((time - s) % (e - s), s, e, 0, 1))
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Mar 29, 2024 Mar 29, 2024

Shamnad5EB1_0-1711714822883.pngexpand image

There is an error!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Mar 29, 2024 Mar 29, 2024

There is probably a problem with your duration value.

The duration needs to be higher than 0.

screenshot.pngexpand image

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Mar 29, 2024 Mar 29, 2024

Yea, it's working now !!
I just want to bring to your attention that the code works perfectly fine if it involves only one layer. However, I am facing issues with the looping functionality when multiple objects are added, particularly with the start and end points. I am not sure if it's due to my lack of knowledge in scripting.
Thanks for your support @Airweb_AE . It means a lot.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Mar 29, 2024 Mar 29, 2024

Try this expression and offset the work area start

d = parent.effect("duration")("Slider");
o = parent.effect("offset")("Slider");
s = framesToTime(o * (index - 1));
e = s + d;
parent.content("Shape 1").content("Path 1").path.pointOnPath(linear((time - s) % (e - s), 0, d, 0, 1))

 screenshot.pngexpand image

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Mar 29, 2024 Mar 29, 2024
LATEST

Your assistance has been invaluable. Thanks to you @Airweb_AE, everything is working perfectly now!  

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines