You mographers probably use a simple loop expression, “loopOut()”. And I think once you’ve thought that you wanted to loop only specific keyframes like an image above. It’s easy to do with expression!
[Expression]
loopOut("cycle", 2);
[Quick Explanation]
loopOut(type="cycle", numKeyframes=0);
loopOut() has 2 arguments, loop type and number of keyframes. The number of keyframes is keyframe segments to loop. If you use “loopOut(“cycle”, 1)”, it loops the segment bounded by the last keyframe and second to last keyframe. See my quick expression sample GIF below. Of course, you can choose your loop type from cycle, pingpong, offset and continue.
Anyway, I recommend you to read the Adobe Help page about loopOut() expression once.
I would much appreciate it if you could give me a feedback. So please don’t hesitate to get in touch with me if you find some errors or better ways.
I hope this tips help you out even just a bit.
This is a site I’ll return to. Awesome work and generosity! Many thanks
Thank you so much for your words, Danny. You made my day!
after year now i finally understand what I do when using loopOut. now I wonder how to say at the expression that I want to loop between specific keyframes ( lets say, between the second and 4th keyframe in your example), without need to use sliders, duplicate comp layers and these sorts of things. Thanks!
Thank you for your comment. I’m glad if it’s helpful for you.
I’m sorry but I’m not sure your goal. But “if/else” conditional might be useful for some cases.
Very good explanation, thanks! I gotta a question.. What if I want to make an animation loop until it reaches a certain point in time? Is that easy to achieve?
Thank you for your comment, Gustavo.
It depends on the situation/condition but how about this expression?
t = 10; // set your time to stop loop
if(time < t){
loopOut("cycle");
} else {
value; // or something you want
}
Thanks a lot Beatgram, this is a cool code snippet. Sheer genius!!
Thank you!! That’s just incredible. It’s my first day of learning After Effects and I already feel like a programmer :))
Exactly what I was looking for ! Thanks alot !
Thank you, Akshay! I’m glad many people left a sweet comment here.
Awesome! Saved me a lot of copy pasting
I’m glad it’s helpful for you, Francisco.
Oh dude, this is the clearest explanation of the loopOut/loopIn I’ve seen, especially the “play once, loop forever” part. If they are not linking to this from the official Adobe AE online help, they should be. Thanks so much for taking the time to write this up 🙂
Thank you so much for your sweet words, Lori! I’m glad you like it.
I think this is just the power of animation/motion graphics to communicate.
I wonder is there any way to make a loop that plays before AND after keyframes. That would help my animation a lot.
I’ve just realised expression “loopIn() + loopOut() – transform.position” can do the work, but is there a more elegant way?
I’m not sure if it’s helpful for you but here’s a typical sample.
if(time < key(1).time){
loopIn();
} else {
loopOut();
}
Thank you! I thought there is some kind of loopInOut() type of command, but now I have at least two working variants.