Join Owen Lowery for an in-depth discussion in this video Cycle loop, part of Motion Graphics Loops 02: After Effects Techniques.
- [Voiceover] When it comes to looping and after effects, expressions are your bestest of friends. Specifically, the Loop Expression, and all of it's varieties. Now, don't get all panicky over a little bit of Java language and typing. The Loop Expression is one of the more simple one's to familiarize yourself with and is a great introduction to Expressions in general. In fact, we'll start dissecting the different looping techniques used to create this Never-Ending, Working Late, animation loop by going over the Cycle Loop Expression in Chapter One, Cycle Loop.
Quick note, there are several hidden layers which I have Shy Guy'd in most of these chapter compositions. These hide the background, title, and textures being used in the animations. You can just ignore the Shy Guy button, because everything you need is enabled and ready to go. So, let's get started familiarizing ourselves with the Loop Expression by using this single falling coffee bean and After Effect's default loop type called, "Cycle". Right here I have a falling coffee bean much like in the Working Late animation loop.
But, I want this to cycle and loop over and over, and over again. So, to do this I need to go to the Properties like Position and Rotation on my coffee bean, and add the Loop Out Cycle Expression. I'll do this to the Position Key Frame by holding down "Option", and clicking on the stop watch. I will type in all lower-case, "loop" and upper-case "O", and then lower-case "ut" for "loopOut". I will type in open parentheses, quote, "cycle", all lower-case, end quote and parentheses.
Then I can just click off. And if we look, the bean now falls and continues to loop after the final key frame. I'll pause playback by hitting the space bar, and now we need to add the same expression to the Rotation Value and I'll do this in a little bit of a different way, because in After Effects, there's more than one way to do anything. I'll go up to Animation, and select "Add Expression" which also adds an expression here. I'll go ahead and type in "loop", all lower-case, capital "O", "ut", then I'm just going to make open parentheses and closed parentheses.
I won't even type "cycle" in, because Cycle is the default Loop Expression for After Effects. So, when I click off, you'll notice that I'm getting the loop of the Position and the Rotation now. I don't even need the word "cycle", awesome. I will pause playback again, and explain that there is a second Value we can add to our Loop Out Cycle Expression. I'm just going to highlight my text here, add a comma, and I will add the number four. Now, what this will do, is loop based on the Key Frames.
It will loop based on the final Key Frames. But, instead of the last four Key Frames themselves, the space in between each of these Key Frames. So, this will count as one, two, three, four. So, if we preview and take a look at what that look's like, our Rotation and our Position is a little bit off. So, I'm going to go ahead and copy this Loop Out Cycle Four Expression by highlighting it, hitting "Command + C", I'm gonna paste it down here by just clicking on it, hitting "Command + V". Now, we can watch them together. So, what's happening right now, is instead of looping the entire animation, it's only looping back the animation that happens between these Key Frames here.
The final five Key Frames, or the final four spaces. Now, there's another way in which we can effect the Loop Out Cycle duration and that is by changing "loopOut" to "loopOutDuration" with a capital "D" and the rest lower-case. I'll do that for both of these, "Duration". And I'm going to change the Value from four to one. Now, instead of basing this on the Key Frames, this one is basing it on the time and seconds.
So, the duration and seconds within this animation. Let's preview, and take a look at what that looks like. So, it's only previewing the last second of animation within the Key Frame's Value. Let's take a look at what that looks like if we do .75 seconds, ".75". And preview, we just get that bean kind of popping up. So, it will play through our original Key Frames, and then it will Loop Out the duration of that last .75 seconds of animation.
Now, there's another kind of Cycle Loop that we can do, and that is Loop In Cycle. I'm gonna pause playback and I'm going to change "loopOutDuration", to just "loopIn". The word loop in all lower-case, "I" in capital, lowercase "n" and just in and out parentheses. So, I'll triple click to copy this expression and just click and paste it down there as well. And now if we watch, it's no longer looping after our Key Frames.
It plays through once and it holds. That's because what Loop In does, is it loops the animation up until it reaches the Key Frames. So, to see how this works, I need to drag and select all of my Key Frames and I'll move them over a few seconds. Now, let's preview. It's looping it over and over until it reaches those final Key Frames, and then it rests. This is a really good way for you to loop an animation and have it come to rest, and control when it stops looping. I'm going to pause playback, bring my Key Frames back to the front of my timeline, and change my Loop In Expression back to "loopOut", and just keep it as it's default cycle, without typing anything in between them.
I tend to use the Loop Out Cycle Expression almost exclusively. Rarely, do I need to stop a loop with the Loop In, but it does come up every now and then. But, overall, once you get the hang of the Loop Out Expression you're probably good for some 90% of the looping that you'll do in After Effects.
- Working with loop expressions
- Looping mash and shape paths
- Combining expressions
- Looping footage with Time Remap
- Looping with effects
- Rendering loops as animated GIFs