View all expressions
Motion

Loop Path

Loops a property's animation, optionally creating a "ping-pong" effect where the animation plays forward and backward alternately.


try {
    timeStart = thisProperty.key(1).time;
    duration = thisProperty.key(thisProperty.numKeys).time - timeStart;
    pingPong = false;
    quant = Math.floor((time - timeStart) / duration);
    if (quant < 0) quant = 0;
    if (quant % 2 == 1 && pingPong == true) {
         t = 2 * timeStart + (quant + 1) * duration - time;
    } else {
        t = time - quant * duration;
    }
} catch (err) {
    t = time;
}
thisProperty.valueAtTime(t);

Loop Path

Practical use case

Use this to have an object (like a car or airplane) continuously follow a looping path, such as driving around a track or flying in a circular route, without needing to manually repeat keyframes.

Check out similar expressions

Data-driven video workflows for After Effects are easier with Plainly.

a mesh of elegant lines transparent image