Skip to main content
Known Participant
June 10, 2024
Question

Using Expressions to Change a Precomp's Framerate / Time-Remapping?

  • June 10, 2024
  • 1 reply
  • 261 views

Hi Everybody,

 

I have a situation where I have a side-scrolling 'game' where the road/foreground, street elements, and background need to travel sideways on an X-axis but at different speeds.

 

Now, there's the hand-made way of creating separate (super long) length of background and then set a keyframe at the beginning and end. But it would be a LOT nicer if I could set three separate precomps in a loopOut() and then change their frame rate by a slider (or something).

 

Is that possible? and if so, are there any tutorials on this subject? Making Precomps more..."object-oriented" (for lack of better wording) would be great for templating and beyond. 

 

Thanks for reading. 🙂

This topic has been closed for replies.

1 reply

Dan Ebberts
Community Expert
Community Expert
June 10, 2024

You could use a "roll your own" loopOut("cycle") expression like this, that would use a Slider Control to set (not animate though) the speed (in percent). So setting the slider to 200 would make it twice as fast, etc.:

spd = effect("Speed")("Slider");
t0 = time*spd/100;
if (numKeys > 1 && t0 > key(numKeys).time){
  t1 = key(1).time;
  t2 = key(numKeys).time;
  span = t2 - t1;
  delta = (t0 - t2);
  t = delta%span;
  valueAtTime(t1 + t);
}else
  valueAtTime(t0)