Skip to main content
Participating Frequently
December 2, 2021
Answered

Start playing a pre-comp at a certain time

  • December 2, 2021
  • 4 replies
  • 2395 views

I have animation about 2 minutes long. It consists of 10 photo frames where each frame shows a simple animation. The camera moves from frame to frame and when the camera focuses on a frame, the animation is played for that frame. Is it possible to start playback of a pre-comp at a certain time in the main comp?

Correct answer Dan Ebberts

I think you'd just turn on time remapping for the pre-comps and use a simple time remapping expression like this to start the playback at a specific time (at 3 seconds, in this example):

tStart = 3;
time - tStart;

The trick is figuring out how the expression knows it's time to start playback. You could use a layer marker, like this:

if (marker.numKeys > 0){
  tStart = marker.key(1).time;
  time - tStart;
}else
  0;

4 replies

Participant
February 12, 2025

@Dan Ebberts Dear Dan,
thank you for this wonderful expression. I'm trying to do the oposit (start at 0 and stop the animation of a precomp at a given marker). Is this possible? I really have no clue and I'm in research-mode since this morning.  Thanks in advance.

Dan Ebberts
Community Expert
Community Expert
February 12, 2025

I'm not sure exactly what behavior you want, but this example should play normally until the first marker, then freeze:

m = marker;
t = time;
if (m.numKeys > 0){
  t = Math.min(time,m.key(1).time);
}
t
Participant
February 13, 2025

thank you so much dan! this whichcraft is exactly what I meant. you helped me a lot with it. Much appreciated. I wish you a pleasent day.  

Dan Ebberts
Community Expert
Dan EbbertsCommunity ExpertCorrect answer
Community Expert
December 2, 2021

I think you'd just turn on time remapping for the pre-comps and use a simple time remapping expression like this to start the playback at a specific time (at 3 seconds, in this example):

tStart = 3;
time - tStart;

The trick is figuring out how the expression knows it's time to start playback. You could use a layer marker, like this:

if (marker.numKeys > 0){
  tStart = marker.key(1).time;
  time - tStart;
}else
  0;
rikilAuthor
Participating Frequently
December 3, 2021

You are a hero! I put the second code in each pre-comp and a Labelmarker where I want the animation to start playing.

Community Expert
December 2, 2021

Just drag the pre-comp forward or backward in the timeline. Pre-comps, or more accurately, nested compositions are just like footage. They have in point, out point, and duration. Where they are in the timeline determines when playback begins.

rikilAuthor
Participating Frequently
December 3, 2021

I was a little vague. The first frame should be visible at all times in each photo frame during the animation and then played at a certain time. If I move the animation along the timeline, they are not visible all the time.

Mylenium
Legend
December 2, 2021

I suggest you read up on time-remapping and all that stuff in the online help if simply staggering the layers doesn't do it. Of course you're still gonna need extra keyframes and also account for the paly time in your camera movement.

 

Mylenium