Copy link to clipboard
Copied
I have a kind of unique situation, where I have an animation on a path, and I want to loopIn the first three keyframes, and then have more animations on that path afterwards that don't get repeated. (In case that didn't make sense, I'll explain the situation being animated. I bring a character on the screen, and she's waving hi. Afterwards, she puts her arm down. I'd like the part where she's waving back and forth to be looped in, but not the part where she puts her arm down.)
I've seen in various places on the web that there are existing expressions for a plain "loopOut" expression for paths (such as here), but I haven't seen any that are "loopIn." And I also haven't found any loopOut expressions that will limit the loop to some of the keyframes.
So, to sum up, what I'd like help with is an expression that would be equivalent to
loopIn("cycle", [INSERT NUM KEYS]);
that would work on path animations. And while you're at it, it would be awesome if you could write an equivalent expression for loopOut that also includes the [INSERT NUM KEYS] part.
Thanks in advance!
I think this will work. It could use some additional code to make sure there are at least nKeys keyframes, but this is the basic method:
nKeys = 3;
if (time > key(1).time){
value;
}else{
d = key(nKeys).time - key(1).time;
t = (key(1).time - time)%d;
valueAtTime(key(nKeys).time - t)
}
Here's the loopOut("cycle",nKeys) version:
nKeys = 3;
if (time < key(numKeys).time){
value;
}else{
t1 = key(numKeys-nKeys+1).time;
d = key(numKeys).time - t1;
t = (time - key(numKeys).time)%d;
valueAtTime(t1 + t)
}
Copy link to clipboard
Copied
I think this will work. It could use some additional code to make sure there are at least nKeys keyframes, but this is the basic method:
nKeys = 3;
if (time > key(1).time){
value;
}else{
d = key(nKeys).time - key(1).time;
t = (key(1).time - time)%d;
valueAtTime(key(nKeys).time - t)
}
Copy link to clipboard
Copied
Thanks Dan! You're the best, as always! Works like a charm. I'll just make sure I only use this expression if I have more than nKeys number of keyframes already put in.
Copy link to clipboard
Copied
Here's the loopOut("cycle",nKeys) version:
nKeys = 3;
if (time < key(numKeys).time){
value;
}else{
t1 = key(numKeys-nKeys+1).time;
d = key(numKeys).time - t1;
t = (time - key(numKeys).time)%d;
valueAtTime(t1 + t)
}
Copy link to clipboard
Copied
Works great! Thanks again Dan.