Skip to main content
Known Participant
February 15, 2021
Answered

Shape path points expresion triggered by markers

  • February 15, 2021
  • 1 reply
  • 1997 views

Hello,

 

Imagine an open shape layer path with let say 5 points. Is it possible to create an expression to have an object move along the shape of the path but hitting the path points at the specific times controlled by markers?

 

So marker 1 will start the animation from point (0) and the duration of the object traveling to point (1) will be decided by the time placement of marker 2 etc.

 

Thank you very much in advance.

This topic has been closed for replies.
Correct answer Dan Ebberts

Dan, thank you very much!

 

Yes, I am trying to build a project that could be used in any situation where we have between 2 and 15 points and the corresponding number of markers.

 

I will try to modify the expression above to fit that scenario.

 

You mentioned there is a better way to do this with more points, if the explanation doesn't take too much of your time please let me know.

 

Thank you again.


This would be the basic idea, but it needs some additional code to handle the situation where the number of points and markers aren't the same:

m = thisComp.marker;
tLayer=thisComp.layer("Shape Layer 1"); 
tPath=tLayer.content("Shape 1").content("Path 1").path;
p = tPath.points(); 

if (m.numKeys > 1){
  n = m.nearestKey(time).index;
  if (time < m.key(n).time) n--;
  if (n == 0){
    tLayer.toComp(p[0]);
  }else if (n == m.numKeys){
    tLayer.toComp(p[n-1]);
  }else{
    p1 = tLayer.toComp(p[n-1]);
    p2 = tLayer.toComp(p[n]);
    ease(time,m.key(n).time,m.key(n+1).time,p1,p2);
  }
}else
  value

1 reply

angie_taylor
Legend
February 15, 2021

Yes, there are at least two ways of doing this. You can either paste the mask path into the position property of the layer. This will paste with roving keyframes but you can change them back to linear keyframes and place them at whatever time you like.

 

or, you could use text animators to move a shape along a path, using the path text feature. This would only work if you used a symbol font for example.

 

in either situation you can reference markers and use something like time remapping. Link the time remapping property to the specific points you want using expressions.

Known Participant
February 15, 2021

Thank you Angie,

 

Time remapping is a nice idea. I may try that.

 

Copy/paste keyframes will not work for me as I would like to have the flexibility to change the path at any time without always repeating this task.

My object is a layer so  I don't think the path text option will apply to me. 

 

I am trying to create an expression to the null layer and so far I can do what I need but with just 2 path points using the expressions below. I am trying to figure out how to do this with many more path points (more than 15) and the corresponding number of markers. Thank you again.

 

SM = thisComp.marker.key(1).time;

SE = thisComp.marker.key(2).time;

tPath=thisComp.layer("Shape Layer 1").content("Shape 1").content("Path 1").path;

tLayer=thisComp.layer("Shape Layer 1");

p1=tLayer.toComp(tPath.points()[1]);

p2=tLayer.toComp(tPath.points()[2]);

ease(time, SM, SE, p1, p2);

Mylenium
Legend
February 15, 2021

Not really much to it. You run it in a for() loop to iterate through all points. How well it will work is anyones guess, though. You may need a ton of extra safeguards to avoid jumpy animation as the time traverses through the points/ marker thresholds, which is actually the complicated part about such stuff. The text could appear to freeze for a short time, parts could self-overlap unfavorably, the text could flip over in unwanted ways. I'm pretty much with Angie on this one - if you can, try to find other ways to solve your issue. Time-remapping doesn't at all sound too bad...

 

Mylenium