Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Rotation with duration, holds for 1 sec. then repeats

  • Rotation with duration, holds for 1 sec. then repeats

    Posted by John Osteen on November 2, 2011 at 11:45 pm

    I’m trying to set up an expression that will rotate a null 36 degrees every second, but I need the rotation to last 5 frames and hold its position until the next second comes around. Does anyone have any ideas on this one? I’m at a complete loss.

    John Osteen
    DastardlyStudios.com

    Roman Stupak replied 6 years, 4 months ago 6 Members · 16 Replies
  • 16 Replies
  • Dan Ebberts

    November 3, 2011 at 12:10 am

    This should be close:

    segDur = 1;
    rampDur = 5*thisComp.frameDuration;
    degrees = 36;
    t = (time – inPoint)%segDur;
    seg = Math.floor(time/segDur);
    degrees*seg + linear(t,0,rampDur,0,degrees)

    Dan

  • John Osteen

    November 3, 2011 at 12:23 am

    Dan, you are the man! Would’ve never figured that out on my own. Thank you.

    One last question though, what would I change if I need another one to rotate every 10 seconds?

    John Osteen
    DastardlyStudios.com

  • Dan Ebberts

    November 3, 2011 at 12:46 am

    segDur = 10;

    Dan

  • Roland R. kahlenberg

    November 7, 2011 at 6:29 pm

    Hi Dan, the Expression script doesn’t seem to like layers not starting at time=0. Is there a way to fix this elegantly?

    Cheers
    RoRK

    Intensive AE & Mocha Training in Singapore and Malaysia
    Adobe ACE/ACI (version 7) & Imagineer Systems Inc Approved Mocha Trainer

  • Dan Ebberts

    November 7, 2011 at 7:52 pm

    Good catch. This should fix it:

    segDur = 1;
    rampDur = 5*thisComp.frameDuration;
    degrees = 36;
    t = (time – inPoint)%segDur;
    seg = Math.floor((time-inPoint)/segDur);
    degrees*seg + linear(t,0,rampDur,0,degrees)

    Dan

  • Roland R. kahlenberg

    November 8, 2011 at 9:42 pm

    Thanks Dan!

    RoRK

    Intensive AE & Mocha Training in Singapore and Malaysia
    Adobe ACE/ACI (version 7) & Imagineer Systems Inc Approved Mocha Trainer

  • John Madison

    April 16, 2012 at 3:56 pm

    Hi Dan,

    I was looking for a similar expression, however my set is slightly different. I was wondering if you can help!

    I have the following set up with stroke-only circles and masks:

    The black bit is just another circle.

    I want to rotate the black circle every 5 frames but not a transitional rotation rather every 5 frames it rotates to its new position (increments of 40 degrees, i.e. overlapping the blue circles) holds for 5 frames and repeats.

    How do i got about achieving this?

    Thanks

  • Dan Ebberts

    April 16, 2012 at 4:05 pm

    This should work:

    f = timeToFrames(time-inPoint);
    value + Math.floor(f/5)*40

    Dan

  • George Judd

    October 23, 2018 at 5:58 pm

    Hey Dan,

    I am trying to achieve a similar effect. However, I need my null to rotate 1 degree every 3 frames and that is all.

    I have been trying to tweak your expression, but my limited understanding of expression hasn’t got me very far!

    If you had any recommendations on books or videos that would help me get a better grasp on expression I’d really appreciate it!

    Many thanks!

    George

  • Dan Ebberts

    October 23, 2018 at 7:55 pm

    Try this:

    f = timeToFrames(time-inPoint);
    value + Math.floor(f/3)

    Dan

Page 1 of 2

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy