• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
1

How to do loopIn("cycle",3) on PATH ANIMATION?

Explorer ,
May 24, 2024 May 24, 2024

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!

TOPICS
Expressions , How to , Scripting

Views

415

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 2 Correct answers

Community Expert , May 24, 2024 May 24, 2024

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)
}

Votes

Translate

Translate
Community Expert , May 24, 2024 May 24, 2024

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)
}

 

Votes

Translate

Translate
Community Expert ,
May 24, 2024 May 24, 2024

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)
}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 24, 2024 May 24, 2024

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.

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 24, 2024 May 24, 2024

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)
}

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 26, 2024 May 26, 2024

Copy link to clipboard

Copied

LATEST

Works great! Thanks again Dan.

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines