Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member

Applying loop expressions

From: 2D Character Animation with After Effects

Video: Applying loop expressions

Now, there's an expression that's really useful to every animator in nearly every situation called the Loop Expression. And that's what we're going to have a look at here. If you want to follow along, you can open up the Expressions and Scripting Project, and that's in the Expressions and Scripting folder. Now, we're going to start with this one here, 058 dog walk cycle. And I'm going to open that, and you'll see that I have this layer in here. And if I preview that, you'll notice I have a dog walk cycle, but it only lasts for a few frames.

Applying loop expressions

Now, there's an expression that's really useful to every animator in nearly every situation called the Loop Expression. And that's what we're going to have a look at here. If you want to follow along, you can open up the Expressions and Scripting Project, and that's in the Expressions and Scripting folder. Now, we're going to start with this one here, 058 dog walk cycle. And I'm going to open that, and you'll see that I have this layer in here. And if I preview that, you'll notice I have a dog walk cycle, but it only lasts for a few frames.

If we have a, step through frame by frame, you'll see we've got a few frames of it, and then it stops. Now, what I want to do is I want to loop this so that he continues walking, okay? And this is a composition, a nested composition. If it was a piece of footage, or a sequence, I could loop it by going into the Interpret Footage dialog box, and choosing Looping Options in there. But this is a nested comp. If I double-click it, you'll see all it is is a series of frames stacked on top of each other.

So, how do I loop it? Well, I've applied Time Remapping to this. And I apply Time Remapping, going to Layer > Time > Enable Time Remapping. And we'll have a look more at Time Remapping a little later. And basically, what time remapping has done is it's added keyframes for the active frames of my animation. So basically, that's going from the beginning to the end of the animation. Now, when you first apply Time Remapping, it will be trimmed up like this. So, I've just trimmed out the end to continue all the way to the end. Now, the last frame is black so I don't really want that frame included. So, the key to making this work is move one frame back from the last keyframe, zoom in to the timeline, and add a keyframe there. So, if you want to add a keyframe of the existing time, you click on the Add or Remove Keyframe at Current Time button.

And then, if we delete this keyframe, the black one, we'll now hold on that frame all the way to the end. So basically, what we've got is we've got the moving frames between here and here, and then we've got static frame all the way to there. So basically, what we want to do is we want to repeat the values between these two frames over and over again to create a walk cycle. And to do that, I'm going to Alt click on Stop Watch and I'm going to add the loop expression, which is in the Property menu.

So if we choose Loop Out, Type Cycle, okay? Now, there's an extra thing in there called Num Keyframes. We don't need that so I'm going to delete the comma and the num keyframes equals zero, and basically we've done it. If I preview that, basically what it's doing is it's looping that section over and over again using a cycle loop. And a cycle loop just keeps going forwards. Now, you'll notice there's another black frame in there. If we go back to the beginning, you'll notice there was a black frame at the beginning.

So again, step forward by one frame, zoom in, add a keyframe there, and then remove that last keyframe at the beginning. And now, we should have a perfect looping dog walk with no black frames in between. Okay, and if we have a look at that property graph by clicking the Graph button for the expression and the Graph Editor, we can see what cycle it does. It just keeps going forwards, keeps going forwards. Okay, so that's a cycle loop allowing us to loop an animation forever, basically.

So, the second loop expression we're going to have a look at is Ping Pong. So, I want you to open up 05B Stick Man Ping Pong. And in here, we have a layer which is basically doing half a walk cycle. So, in order to make him walk, I'm going to have to go forwards, backwards, forwards, backwards as opposed to the last one, which just wanted to keep going forwards. Now, I've applied Time Remapping and I'm going to stretch the layer out to fill the whole gyration, and then I can add an expression to the Time Remap property.

And again, click on my Expression Language, choose Property > Loop Out. And this time, I'm going to edit it and instead of cycle, we're going to type Ping Pong, and the Ping Pong loop will go forwards, backwards, forwards, backwards, and it should create the effect we want for this walk cycle. And if I preview that, see, we now have our character walking forwards, backwards, forwards, backwards. Again, if you get the black frame in there, you just need to go to your last frame, zoom in, move one frame before, add the keyframe there, and then just delete that black keyframe.

And now, we should have our character walking for as long as we want, going backwards, forwards, backwards, forwards. And let's have a look at the Expression Graph. And if I zoom out, you'll see basically, it's moving forwards, backwards, forwards to create that kind of loop, which is a ping pong loop. Now, the third and final looping expression. If you open up 05C Stick Man Continue, is the continue expression. Now, here we have a character getting bigger over time.

And what I want to do is make him walk across the screen. So, what I'm going to do is use motion sketch. I'm going to click on the character. I'm going to get my pen and my Wacom tablet because that's the best thing to use for capturing motion and applying it to your characters. Click on the Start Capture button, and now all the movement that I make with my pen on my tablet will be captured and applied to the character. But sometimes, you'll find that you accidentally let go at one point, or something goes wrong with it, and I'm going to show you how the loop expression can help with that.

So, here we go. He's walking towards the screen. And then, I run out of time or I run out of space on my Wacom tablet. And I've got a nice movement. But as I said, I ran out of time. So, what do I do? Well, I could capture the whole thing again. Or if I just want him to continue walking in that direction at the same speed, and what I can do is apply the continue loop expression. So, Alt click on the Stopwatch, go down to the Property section of the Expression Language menu, and loop out again. And this time, what we're going to do is type in, continue. Okay, so make sure I spell it correctly, continue.

Spelling is not by big strong point. And then, delete the text that we don't need. And now, if we preview that, we should see he walks along, and then he continues moving at the same speed in the same direction until he goes off screen. So, if you've done a motion path and it's slightly short and you just want to keep someone going at the same speed, then you can use continue expression to do that. Okay, so if we have to look at the end composition, here we see it again.

Okay, I have't quite got my timing right by that one, but you get the idea of how that works. So, those are the three looping expressions, cycle, ping pong, and continue.

Show transcript

This video is part of

Image for 2D Character Animation with After Effects
2D Character Animation with After Effects

27 video lessons · 2757 viewers

Angie Taylor
Author

 

Start learning today

Get unlimited access to all courses for just $25/month.

Become a member
Sometimes @lynda teaches me how to use a program and sometimes Lynda.com changes my life forever. @JosefShutter
@lynda lynda.com is an absolute life saver when it comes to learning todays software. Definitely recommend it! #higherlearning @Michael_Caraway
@lynda The best thing online! Your database of courses is great! To the mark and very helpful. Thanks! @ru22more
Got to create something yesterday I never thought I could do. #thanks @lynda @Ngventurella
I really do love @lynda as a learning platform. Never stop learning and developing, it’s probably our greatest gift as a species! @soundslikedavid
@lynda just subscribed to lynda.com all I can say its brilliant join now trust me @ButchSamurai
@lynda is an awesome resource. The membership is priceless if you take advantage of it. @diabetic_techie
One of the best decision I made this year. Buy a 1yr subscription to @lynda @cybercaptive
guys lynda.com (@lynda) is the best. So far I’ve learned Java, principles of OO programming, and now learning about MS project @lucasmitchell
Signed back up to @lynda dot com. I’ve missed it!! Proper geeking out right now! #timetolearn #geek @JayGodbold
Share a link to this course

What are exercise files?

Exercise files are the same files the author uses in the course. Save time by downloading the author's files instead of setting up your own files, and learn by following along with the instructor.

Can I take this course without the exercise files?

Yes! If you decide you would like the exercise files later, you can upgrade to a premium account any time.

Become a member Download sample files See plans and pricing

Please wait... please wait ...
Upgrade to get access to exercise files.

Exercise files video

How to use exercise files.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.


Exercise files

Exercise files video

How to use exercise files.

For additional information on downloading and using exercise files, watch our instructional video or read the instructions in the FAQ.

This course includes free exercise files, so you can practice while you watch the course. To access all the exercise files in our library, become a Premium Member.

Join now "Already a member? Log in

Are you sure you want to mark all the videos in this course as unwatched?

This will not affect your course history, your reports, or your certificates of completion for this course.


Mark all as unwatched Cancel

Congratulations

You have completed 2D Character Animation with After Effects.

Return to your organization's learning portal to continue training, or close this page.


OK
Become a member to add this course to a playlist

Join today and get unlimited access to the entire library of video courses—and create as many playlists as you like.

Get started

Already a member?

Become a member to like this course.

Join today and get unlimited access to the entire library of video courses.

Get started

Already a member?

Exercise files

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships. Learn more

Get started

Already a Premium member?

Exercise files video

How to use exercise files.

Ask a question

Thanks for contacting us.
You’ll hear from our Customer Service team within 24 hours.

Please enter the text shown below:

The classic layout automatically defaults to the latest Flash Player.

To choose a different player, hold the cursor over your name at the top right of any lynda.com page and choose Site preferencesfrom the dropdown menu.

Continue to classic layout Stay on new layout
Exercise files

Access exercise files from a button right under the course name.

Mark videos as unwatched

Remove icons showing you already watched videos if you want to start over.

Control your viewing experience

Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.

Interactive transcripts

Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.

Are you sure you want to delete this note?

No

Your file was successfully uploaded.

Thanks for signing up.

We’ll send you a confirmation email shortly.


Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from lynda.com.

Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

   
submit Lightbox submit clicked
Terms and conditions of use

We've updated our terms and conditions (now called terms of service).Go
Review and accept our updated terms of service.