ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

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

FAQ   •   VIEW ALL
 Rotation with duration, holds for 1 sec. then repeats on Nov 2, 2011 at 11:45:44 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

 Re: Rotation with duration, holds for 1 sec. then repeatson Nov 3, 2011 at 12:10:26 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

 Re: Rotation with duration, holds for 1 sec. then repeatson Nov 3, 2011 at 12:23:49 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

 Re: Rotation with duration, holds for 1 sec. then repeatson Nov 3, 2011 at 12:46:22 am

segDur = 10;

Dan

 Re: Rotation with duration, holds for 1 sec. then repeatson Nov 7, 2011 at 6:29:16 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

 Re: Rotation with duration, holds for 1 sec. then repeatson Nov 7, 2011 at 7:52:02 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

 Re: Rotation with duration, holds for 1 sec. then repeatson Nov 8, 2011 at 9:42:11 pm

Thanks Dan!

RoRK

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

 Re: Rotation with duration, holds for 1 sec. then repeatson Apr 16, 2012 at 3:56:02 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

 Re: Rotation with duration, holds for 1 sec. then repeatson Apr 16, 2012 at 4:05:24 pm

This should work:

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

Dan

 Re: Rotation with duration, holds for 1 sec. then repeatson Oct 23, 2018 at 5:58:17 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

 Re: Rotation with duration, holds for 1 sec. then repeatson Oct 23, 2018 at 7:55:18 pm

Try this:

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

Dan