Skip to main content
Participant
May 23, 2023
Question

Object following trim path

  • May 23, 2023
  • 2 replies
  • 1469 views

Hi

 

I have a trim path and an object that I would like to follow the tip of the trimpath. I believe something goes wrong with the conversion of layer-posistion to comp-position. Here's the expression i'm using:

 

var path = thisComp.layer("cable").content("Group 1").content("Path 1").path;

var trimPath = thisComp.layer("cable").content("Group 1").content("Trim Paths 1").end/100;

var targetLayer = thisComp.layer("cable"); var point = path.pointOnPath(trimPath); targetLayer.toComp(point);

This topic has been closed for replies.

2 replies

LW0121
Inspiring
June 12, 2024

This doesn't work well if I turn on the path direction in After Effects. How to modify the expression then?

Dan Ebberts
Community Expert
Community Expert
June 12, 2024

Are talking about Auto-Orient > Orient Along Path? Can you post a screen shot that shows what's going wrong?

LW0121
Inspiring
June 13, 2024

Thank you for your quick response!! I concluded with two questions here:

  1. We know that the path has a direction (start point - end point). If I create a trim path and animate the TrimPathEnd keyframe, and I realize it's an opposite direction, I would click "Reverse Path Direction On". However, if I apply the expression the author wrote here to an object, it still goes the original direction, rather than following the reversed trim path direction. So my first question is is there a way to adjust the expression so the object will also follow the reversed path?
  2. You may ask why I can't draw the path in the right direction. Sometimes, I import these lines from AI files by using Overlord. My second question would be is there a way in AI to reset the start point? (I know in After Effects, I can select the new point and select "Set First Vertex", but it doesn't work for an unclosed path I guess )

Thank you!

 

Dan Ebberts
Community Expert
Community Expert
May 23, 2023

Your code works for me. Is your plug anchor point located where you want the plug to attach to the cable?

Participant
May 23, 2023

Thank you for your reply. And sadly yes, the anchor point is placed at the butt of the plug. But I already cheated my desired outcome by pre-composing it and moving it in place.