Copy link to clipboard
Copied
I've got a composition with a few layers of precomps. I enabled Time Remapping on each and added this script:
loopOut(loop="cycle",numKeyframes=0)
Works great. I'd love to be able to limit the number of times the animation loops, though. Is that possible?
Thanks much!
Hi!
Dan's expression is wonderful but I am wondering is it possible to add an option to it? I want to be able to set the range of the loopOut so it only affects the kyframes within that range. Let's say I have an object and it does this:
1) At the beginning of the comp it changes its position couple of times (no loop needed)
2) In the middle of the comp it jumps and I want to loop this jump 5 times using Dan's expression
3) At the end of the comp the object changes it position couple of times (no lo
...Copy link to clipboard
Copied
Actually, this is better because it lets you define any number of loop areas with comp marker pairs and you don't have to modify the expression:
nLoops = 2;
m = thisComp.marker;
t = time;
if (m.numKeys > 1){
n = m.nearestKey(time).index;
if (time < m.key(n).time) n--;
if (n > 0 && ! (n%2)){
t1 = m.key(n-1).time;
t2 = m.key(n).time;
loopDur = t2 - t1;
if (time > t1 && time < t1 + nLoops*loopDur){
t = t1 + (time - t1)%loopDur;
}
}
}
valueAtTime(t)
Copy link to clipboard
Copied
Last expression is indeed the most practical but I can't set different loop counts for every animation. Every animation in the comp has a fixed duration.
Copy link to clipboard
Copied
I'm not sure what you mean by the last part.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Your screenshot shows a couple of sets of keyframes you want to loop. There may not be enough time between the first set of keyframes and the second set of keyframes for two loops to take place, but there is definitely not enough time between the second set of keyframes and the two keyframes at the end of the timeline for four more loops.
I don't have a suggestion for the expression, but I just wanted to point that out incase another user was confused.
I would also suggest you not use the Drag & drop here button for screenshots. You can copy and paste or drag them to the reply field so you can see them when writing a post, or even use the Toolbar to embed the images.
Copy link to clipboard
Copied
This is the only thing I can think of. With this version, you can specify the number of loops with the comment of the first marker of the marker pair. If you don't put a number in the marker comment, the expression will use what you have defined for nLoops:
nLoops = 2;
m = thisComp.marker;
t = time;
if (m.numKeys > 1){
n = m.nearestKey(time).index;
if (time < m.key(n).time) n--;
if (n > 0 && ! (n%2)){
t1 = m.key(n-1).time;
t2 = m.key(n).time;
loopDur = t2 - t1;
c = m.key(n-1).comment;
nL = (c != "" && ! isNaN(parseInt(c))) ? parseInt(c) : nLoops;
if (time > t1 && time < t1 + nL*loopDur){
t = t1 + (time - t1)%loopDur;
}
}
}
valueAtTime(t)