By using the loop expression, you can create an endlessly repeating animation with only 3 keyframes. For example, use the loop expression on a walk cycle, to easily cycle through a leg movement.
How to Use loop()
ALT+click the stopwatch on any property with keyframes, to add the expression.
Write loopOut() in the expressions field and click somewhere outside of the field to close the expression or hit Enter on your numPad/extended keyboard.
You don’t need to write anything in the brackets. The default loop type is cycle, which means the first and last keyframes need to match for the loop to look seemless.
LoopOut() will cycle the keyframes, starting with the the last keyframe in the set, moving forward in the timeline.
How to Change Loop Type
Although cycle is the default type of the loopOut() expression, if nothing is changed inside the brackets of the function, there are other types of loops that change how the loop function behaves. By using the PingPong type of the loopOut() expression, you can quickly loop with just two keyframes.
Add type = “pingpong” inside brackets of the loopOut() expression. The PingPong type bounces the animation back and forth between the first and last keyframes of the set. If you have a lot of keyframes, you don’t need to make sure for the first and last keyframes match, as PingPong will play the animation forward and then backward to create a loop.
Loop Selected Keyframes Within a Set
If you have a set of keyframes on a property but you only want to loop the last few, there is an option for that with numKeyframes. Add a comma after your loop type and write numKeyframes = value. Replace the word value with the number of your choice.
You can choose the number of keyframe sets, you want to loop at the end of the row of keyframes. The value refers to one set, meaning two keyframes. i.e. 1 = 2 keyframes, 2 = 4 keyframes etc.
By limiting the value of numKeyframes to e.g. 1, no matter how many keyframes are on the property, only the last of two keyframes will be looped at the end of the set.
Copy/Paste an Expression
Any expression can be copied and pasted onto another layer property even if this property is on another layer.
Right click the property and choose Copy Expression Only. Highlight another layer and hit CTRL+V to paste the expression to the layer.
The expression is automatically pasted to the same property it was copied from.
If you want to paste the expression to a different property on another layer, make sure to highlight that layer’s property first.
If you copied an expression from a Separated Dimension, make sure to perform this step, before pasting the expression.
Want to Master Expressions?
Join my Motion Graphics Template Course. Enrol Today!
Personalise branded graphics for your YouTube or talking heads video. Learn new and advanced expressions and create responsive, modular templates.