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

rotate expression

Explorer ,
Oct 16, 2018 Oct 16, 2018

I would like to rotate something back and forth, every 4 seconds. How do I add the 4 sec variable to a loop expression? I assume AE can do this, I'd prefer not to keyframe it. Thanks.

13.0K
Translate
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 ,
Oct 16, 2018 Oct 16, 2018

The easiest thing to do is set one keyframe for rotation at 0 seconds then a second keyframe at 4 seconds. If you want the rotation to go back and forth then add this expression:

loopOut("pingpong")

If you want the rotation to loop then use this expression:

loopOut()

If you want the loop to be seamless then the first and last keyframe must put the layer in exactly the same position.

Translate
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 ,
Oct 16, 2018 Oct 16, 2018

Thanks. So I want to rotate to the left, pause 4 seconds and rotate back to the right (starting position), pause 4 seconds. I thought maybe there was a way to do it using a loop expression with a pause.

Translate
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 ,
Oct 16, 2018 Oct 16, 2018

I think you don't get Rick answer, please take a look on this link so you can understand better how to use loopOut("pingpong")

https://www.schoolofmotion.com/blog/loop-expression-after-effects

Translate
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
Guide ,
Oct 16, 2018 Oct 16, 2018

You can use something like this to do it without keyframes. This only does the first 4 seconds but you can adapt it. Plus you can add expression controllers to control the speed.

if (time<4) time*50;

else

time*-50

Translate
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
Guide ,
Oct 16, 2018 Oct 16, 2018

Alternatively you could really simplify it by using a Cosine wave to control rotation, something like;

Math.cos(time*.75)*100

The multiplier number outside the parentheses controls the amount of rotation. the multiplier number inside the parentheses controls the timing.

Translate
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
Guide ,
Oct 16, 2018 Oct 16, 2018

Here's another with a pause between 4 seconds and 8 seconds;

if (time<4) time*50;

else

if (time>8 & time<12) time*-50

BTW There is a dedicated After Effects Expressions forum which would be a better place for this as it is manned by the wonderful Dan 🙂

Translate
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 ,
Oct 16, 2018 Oct 16, 2018

Thanks. pingpong didn't do it for me. The tutorial was good but didn't provide an obvious solution. I will now try Angie's suggestions, will have to get my math on...

Translate
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
Advisor ,
Oct 16, 2018 Oct 16, 2018

what's the issue with: 2x keyframes +  loopOut("pingpong") ?

What's not working for you?

Translate
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 ,
Oct 16, 2018 Oct 16, 2018

Sorry for the quality. The crab on the left was my goal, here accomplished using a series of keyframes. The crab on the right is the pingpong method, key frames at 0 and 2 sec. I didn't see how to get it to pause.

Translate
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 ,
Oct 16, 2018 Oct 16, 2018

Without any keyframes, it might look something like this:

period = 2;

rotationDur = 0.25;

rotationAmt = 30;

t = time%period;

if (t < period/2){

  ease(t,0,rotationDur,rotationAmt,0);

}else{

  ease(t,period/2,period/2 + rotationDur,0,rotationAmt);

}

Dan

Translate
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
Guide ,
Oct 16, 2018 Oct 16, 2018

You ARE the man Dan. I was wondering if there was a better way than my suggestions. One thing I can’t understand is why the rotation duration is .25 and not .75? Am I missing something obvious?

thanks Dan - King of Expressions  

Translate
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 ,
Oct 16, 2018 Oct 16, 2018

Hi Angie,

>Am I missing something obvious?

Probably not. It was just a rough guess based on the little movie. It looked like the rotation took about 1/4 of the time and the pause the other 3/4.

Dan

Translate
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
Guide ,
Oct 16, 2018 Oct 16, 2018

I’d recommend using Dan’s expression as you I’d you preferred not to use key frames but if you do decide to go down the key frame route, to create the pause, create your first two KFs for the rotation, then add another KF to create a 2 second pause ( toggle hold the 1st). Then add a pinpong loop to this.

Translate
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
Contributor ,
Oct 16, 2018 Oct 16, 2018

ProTip: Any time you have an expression question, google it with 'Ebberts' attached to it. Dan Ebberts is the man with expressions. His answers are always the right ones. And he has a site (motionscript.com) that is super helpful.

Translate
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
Guide ,
Oct 16, 2018 Oct 16, 2018

Ah, OK, I wondered if there was some “magic” for working that out. Thanks Dan 🙂

Translate
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
Mentor ,
Oct 17, 2018 Oct 17, 2018

Even if the expression-solution is a great way, this can be done with a simple loopOut(“pingpong”); - Loop as suggested in the first place.

The trick to "hold" the loop is to add another - 3rd - keyframe with the last rotation value on it. To adjust the pause, you just drag the last keyframe around.

Cheers,

Martin

Translate
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 ,
Oct 17, 2018 Oct 17, 2018
LATEST

Interesting answers and dialogue. Thanks...

Translate
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