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

Start playing a pre-comp at a certain time

New Here ,
Dec 02, 2021 Dec 02, 2021

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?

TOPICS
Expressions , How to
2.2K
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

Community Expert , Dec 02, 2021 Dec 02, 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;
Translate
LEGEND ,
Dec 02, 2021 Dec 02, 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

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 Expert ,
Dec 02, 2021 Dec 02, 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.

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
New Here ,
Dec 02, 2021 Dec 02, 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.

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 Expert ,
Dec 02, 2021 Dec 02, 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;
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
New Here ,
Dec 02, 2021 Dec 02, 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.

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 27, 2024 Mar 27, 2024

Genious, thanks a lot!

Is there a way to start the compostion all over again with a second and third and fourth marker?

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 Expert ,
Mar 27, 2024 Mar 27, 2024

Try this:

t = 0;
m = marker;
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
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 27, 2024 Mar 27, 2024

that works, awesome! Thanks a million :))

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
New Here ,
Feb 12, 2025 Feb 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.

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 Expert ,
Feb 12, 2025 Feb 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
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
New Here ,
Feb 13, 2025 Feb 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.  

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
New Here ,
Feb 13, 2025 Feb 13, 2025

Dan, it's me again. I connected the number of the marker to a slider control, which works like a charm.

 

m = marker;
t = time;
if (m.numKeys > 0){
t = Math.min(time,m.key(thisComp.layer("Controller").effect("1")("Schieberegler")).time);
}
else 0;

 

Thank you a million times again.

 

Just out of curiosity... Let's say I want to start the animation at a certain marker and stop it at another certain marker with it's correnspondending contents in a precomposition (as example a counter from zero to nine and every marker number is representing the number in the precomposition at that time).

 

My approach was this (which you can guess is not working):

 

m = marker;
t = time;
startKey = thisComp.layer("Controller").effect("Start")("Schieberegler");
stopKey = thisComp.layer("Controller").effect("Stop")("Schieberegler");

if (m.numKeys > 0) {
startTime = m.key(startKey).time;
stopTime = m.key(stopKey).time;
if (t < startTime) {
t = startTime;
} else if (t > stopTime) {
t = stopTime;
}
}
t;

 

Where is my mistake? I just don't get it... This is just to much coding for me 😄

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 Expert ,
Feb 13, 2025 Feb 13, 2025
LATEST

Like this maybe:

m = marker;
t = time;
startKey = thisComp.layer("Controller").effect("Start")("Slider");
stopKey = thisComp.layer("Controller").effect("Stop")("Slider");
try{
  tStart = m.key(startKey).time;
  tStop = m.key(stopKey).time;
  t = linear(time,tStart,tStop,tStart,tStop);
}catch(e){
}
t

 

 

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