Loop Path in After Effects

6 min
Loop Path in After Effects
Details (6 min read)

Cat’s tail on the preview is an animated path and I’ll show you how to loop it.
How to loop a path in After Effects?
Alt-click on the Path property and paste an expression below.

// if you don't need pingpong - false
pingPong = false;
try{
// start - first keyframe
timeStart = thisProperty.key(1).time;
// count duration
duration = thisProperty.key(thisProperty.numKeys).time - timeStart;

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

// cycle number
quant = Math.floor((time – timeStart) / duration);
if (quant < 0) quant = 0 // != 0
if (quant % 2 == 1 && pingPong == true){
t = 2 * timeStart + (quant+1) * duration – time;
} else {
t = time-quant*duration;
}

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

} catch(e) {
t = time;
}
thisProperty.valueAtTime(t);
This expression works in the same way as a standard loop cycle expression below.

loopOut(type="cycle");

 
 
How to loop a path like “pingpong”?
Alt-click on the Path property and paste an expression below.

// if you don't need pingpong - false

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

pingPong = true;
try{
// start – first keyframe
timeStart = thisProperty.key(1).time;
// count duration
duration = thisProperty.key(thisProperty.numKeys).time – timeStart;
// cycle number
quant = Math.floor((time – timeStart) / duration);
if (quant < 0) quant = 0 // !=0
if (quant % 2 == 1 && pingPong == true) {

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

t = 2 * timeStart + (quant + 1) * duration – time;
} else {
t = time – quant * duration;
}
} catch(e) {
t = time;
}
thisProperty.valueAtTime(t);
This expression works in the same way as a standard loop “pingpong” expression below.

loopOut(type="pingpong");

 

Our Bestsellers

Summary ( min read)

Our Bestsellers