Skip to main content
Participant
May 11, 2024
Answered

Help with Time Remap expression

  • May 11, 2024
  • 1 reply
  • 561 views

Help me with expression... 

I have comp “ONE”, there in layer “TWO” comp with animation (10 sec).
I need that when animated, from right to left, comp “TWO” crosses comp “ONE” in the middle, in comp “TWO” starts animation from the first frame (before the intersection, the animation should be frozen on the 1st frame).

I need this expression as property layer “TWO” - Time remap.

Thanks.

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

Oops -- I think that's backwards (left to right). This should work for right to left:

c = thisComp.width/2;
if (position[0] > c){
  0;
}else{
  f = timeToFrames(time)-1;
  while (f > 0){
    if (position.valueAtTime(framesToTime(f))[0] > c) break;
    f--;
  }
  time - framesToTime(f);
}

1 reply

Dan Ebberts
Community Expert
Community Expert
May 11, 2024

Try this:

c = thisComp.width/2;
if (position[0] < c){
  0;
}else{
  f = timeToFrames(time)-1;
  while (f > 0){
    if (position.valueAtTime(framesToTime(f))[0] < c) break;
    f--;
  }
  time - framesToTime(f);
}
Dan Ebberts
Community Expert
Dan EbbertsCommunity ExpertCorrect answer
Community Expert
May 11, 2024

Oops -- I think that's backwards (left to right). This should work for right to left:

c = thisComp.width/2;
if (position[0] > c){
  0;
}else{
  f = timeToFrames(time)-1;
  while (f > 0){
    if (position.valueAtTime(framesToTime(f))[0] > c) break;
    f--;
  }
  time - framesToTime(f);
}
Participant
May 12, 2024

Hi! Thanks for help, but I have anothe problem with that script.

I have 30-40 layers with this script, and the rendering load is increasing, and the speed after 50% rendering gradually drops to zero, because after passing the middle of the screen more and more layers start executing the while loop.
For some reason my modification
if (position[0] > c)
to
if (position[0] > c && position[0] < 1920) (screen width)
to prevent the loop from executing when the layer goes out of view
does not work correctly.


I don`t understand why, can u help me?

Thnks!