The loopOut expressions is used so many times in our workflow.
Unfortunately, it’s not working for a path. But we have the solution for you. Just use this expression, and it will be working even with the path:
timeStart = thisProperty.key(1).time;
duration = thisProperty.key(thisProperty.numKeys).time-timeStart;
pingPong = true;
quant=Math.floor((time-timeStart)/duration);
if(quant<0) quant = 0 //no negative numbers
if(quant%2 == 1 && pingPong == true){
t = 2timeStart+ (quant+1)duration - time; }
else{
t = time-quant*duration; }
}
thisProperty.valueAtTime(t)
Congratulations on the new achievement. Now you can loop the path with expressions! Woohoo!
How to loop path with expression in After Effects
In Adobe After Effects, you can create looped animations using expressions. A loop expression allows you to repeat a specific animation or movement indefinitely. Here’s an example of a loop expression in After Effects:
- Create a new composition by going to “Composition” > “New Composition” or using the shortcut Ctrl+N (Windows) or Command+N (Mac).
- Create a new solid layer by going to “Layer” > “New” > “Solid” or using the shortcut Ctrl+Y (Windows) or Command+Y (Mac).
- Select the solid layer and press the letter ‘P’ on your keyboard to reveal its position property.
- Alt-click (Windows) or Option-click (Mac) on the stopwatch icon next to the Position property. This will open the expression editor.
- Enter the following expression:
loopOut(“cycle”); - Close the expression editor.
Now, the solid layer will continuously loop its position animation. If you move the layer in the timeline After Effects will automatically generate keyframes to create a seamless loop.
You can customize the loop expression to fit different types of animations or properties. Here are a few variations:
- loopOut(“cycle”, numKeyframes): Specifies the number of keyframes to use for the loop. For example, loopOut(“cycle”, 3) will create a loop using the last three keyframes.
- loopOut(“pingpong”): Makes the animation play forward and backward, creating a ping-pong effect.
- loopOut(“offset”, numKeyframes): Offsets the loop by a certain number of keyframes.
These are just a few examples of what you can do with loop expressions in After Effects. Experiment with different expressions and parameters to achieve the desired looping effect for your animations.
What is the Motion Beast course?
This is the must-see course for any Motion Designer. It lays the foundation for all aspects of modern motion design and covers every topic from AE basics to character rigging and frame-by-frame animation.
The course will help you overcome AE-related barriers and fears which are standing between you and the wonderful world of animation and motion design
ONLINE COURSE
Motion Beast
Top 5 time-saving Extensions for After Effects
If you animate your works in After Effects and still don’t use the extensions I’m both happy and sad for you. Read this short article till the end and your life will never be the same again.1. OverlordPreparing source files for animation is one of the most time-consuming phases of the animator’s work. Cutting characters […]
Blending Modes in After Effects
In this Very quick but very useful, we will know how to use blending mode. Just use difference mode and here you are ?Blending Modes in After EffectsIn Adobe After Effects, blending modes are used to control how different layers or elements interact and blend with each other. They determine how the colors, brightness, and […]
4 Advanced After Effects Expressions Made Easy
Denys is the Motion Design School’s script wizard and the author of the Expression Trip course. In this article, he will share how expressions can be used to create more complex animation.Popular expressionsAs you’ve learned from the previous article on top 3 After Effects Expressions to simplify your workflow, programming in After Effects, besides being totally not […]