Fix Loop Bug in After Effects

3 min
Details (3 min read)

Recently I discovered a nasty bug when looping time remap. I’ll try to explain it on the screenshot below.

 
The result is we lost 2 frames of animations. When precision matters, it sucks.
The main point is if you think there is something wrong with your time remap loop try the expression below instead of default loopOut.

// start - first keyframe

-50%
-50%
00hrs : 00mins : 00sec
Happy HolidaysSale sitewide
Shop now

timeStart = thisProperty.key(1).time;
// count duration
duration = thisProperty.key(thisProperty.numKeys).time + thisComp.frameDuration – timeStart ;
// cycle number
quant = Math.floor((time – timeStart) / duration);
if (quant < 0) quant = 0 // != 0
if (((time – timeStart) / duration).toString() == Math.floor((time + thisComp.frameDuration – timeStart) / duration)) {
t = timeStart;
} else {
t = time – quant * duration;
}
thisProperty.valueAtTime(t);

-50%
-50%
00hrs : 00mins : 00sec
Happy HolidaysSale sitewide
Shop now

You can also change the variable pingPong to true if you need a pingpong animation instead.
I spent 2 days only figuring out what was the problem, hope it helps someone.
Let me know in the comments if it did the trick for you.
 

Our Bestsellers

Summary ( min read)

Our Bestsellers