Skip to main content
Inspiring
November 8, 2022
Answered

Layer starts over at comp marker

  • November 8, 2022
  • 2 replies
  • 1126 views

I recently asked for help to correlate multiple keyframes to markers, and it worked really well. I now have a somewhat similar question for another part of the same project.

 

My question is two-fold. and it's a bit hard to explain. Here's what I'm working on.

 

 

My previous question was for the "Line" layer there, such that at each marker, the line goes from one dot on the timeline to the next. That works. What I'd like to do now is I'd like the "Camera flash" layer to start over each time it reaches the marker. "Camera Flash" is another comp in my project which I brought into this comp. Currently, obviously, it only plays once. I'd like for it to play as many times as I want without having to copy-paste the layer over and over. I want to be able to just place a marker, and it automatically plays again, no matter how many markers I have. I already gave a try myself at adapting Dan Ebberts's code, and I failed miserably. 😛

 

The second part of my question is wondering if this could be done with comp markers rather than layer markers, so that I can correlate both of these layers to the same markers. It would just make things easier. Alternatively, I do have a "Controller" layer in this comp, so it would also work for me if they were correlated to "Controller" layer markers rather than to comp markers.

 

If this second part isn't possible, that's fine. It would just further streamline my animation creation.

 

Thanks for any help you can offer!

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

This should work with comp markers:

m = thisComp.marker;
t = 0;
if (m.numKeys > 0){
  n = m.nearestKey(time).index;
  if (time < m.key(n).time) n--;
  if (n > 0) t = time - m.key(n).time;
}
t

2 replies

Mylenium
Legend
November 8, 2022

Markers are markers and aside from the syntax differences in adressing them AE doesn't care. Your repeats can easily be achieved by enabling time-remapping on your pre-comp. It would simply reset the time to zero every time you reach a marker and then play as normal.

 

Mylenium

Inspiring
November 8, 2022

Alright, cool.

So, in the old code, I can just replace

m = marker;

with

m = thisComp.marker;

and I should be good to go then. Thanks!

 

Inspiring
November 8, 2022

Also, I doubt this matters much, but "Camera Flash" has both video and audio, and I'd like both to replay when it hits a marker.

 

Dan Ebberts
Community Expert
Dan EbbertsCommunity ExpertCorrect answer
Community Expert
November 8, 2022

This should work with comp markers:

m = thisComp.marker;
t = 0;
if (m.numKeys > 0){
  n = m.nearestKey(time).index;
  if (time < m.key(n).time) n--;
  if (n > 0) t = time - m.key(n).time;
}
t
Inspiring
November 8, 2022

You're the best. 🙂 Thanks.