Loop Path in After Effects

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; 
  // 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;
  }
} 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
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) { 
    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");

 

-50%
-50%
00hrs : 00mins : 00sec
Early Black FridaySale sitewide
Shop now

Get 10% off when you subscribe to our newsletter

By subscribing you agree to your email being stored and used to receive the emails in accordance to our Privacy Policy
descount