Skip to main content
jcalcina
Inspiring
October 16, 2018
Question

rotate expression

  • October 16, 2018
  • 7 replies
  • 13395 views

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.

    7 replies

    jcalcina
    jcalcinaAuthor
    Inspiring
    October 17, 2018

    Interesting answers and dialogue. Thanks...

    angie_taylor
    Legend
    October 17, 2018

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

    Martin_Ritter
    Legend
    October 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

    Inspiring
    October 17, 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.

    jcalcina
    jcalcinaAuthor
    Inspiring
    October 17, 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.

    Dan Ebberts
    Community Expert
    Community Expert
    October 17, 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

    angie_taylor
    Legend
    October 17, 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  

    angie_taylor
    Legend
    October 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

    angie_taylor
    Legend
    October 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.

    OussK
    Community Expert
    Community Expert
    October 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

    Community Expert
    October 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.

    jcalcina
    jcalcinaAuthor
    Inspiring
    October 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.