FORUMS: list search recent posts

Staggered layer rotation with min/max

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Justin Crowell
Staggered layer rotation with min/max
on Jun 24, 2014 at 11:20:44 pm

Hi All,
I've been trying to piece this together for a few hours.

I have six layers. I want them to rotate from 0 to 900 degrees as I drag a slider. BUT...I want the rotations to be staggered according to the layer index.

So, my plan was to do something like below.


So...my Y Rotation slider value (which would be animated from 0 to 900), minus the layer's index multiplied by the delay slider value.

This works well...the only issue is that when the Y Rotation slider is at zero, my higher index layers are negatively rotated, and then when the slider reaches 900, none of the layers are rotated all the way, and if I rotate beyond that, they keep on going.

I need some way to set a max of 900, and a min of 0 for the rotations of each of the layer.

Any thoughts?
Thanks!
-J

thisComp.layer("Controls").effect("Y Rotation")("Slider") -
index*thisComp.layer("Controls").effect("Y Rotation Delay")("Slider")


Editor, Producer, DP
JustinCrowell.com


Return to posts index

Kevin Camp
Re: Staggered layer rotation with min/max
on Jun 24, 2014 at 11:46:38 pm

i would probably use valueAtTime() for something like this...

with your existing sliders, you could use an expression like this to drive y rotation:

ctrl = thisComp.layer("Controls");
yRot = ctrl.effect("Y Rotation")("Slider");
delay = ctrl.effect("Y Rotation Delay")("Slider");
yRot.valueAtTime(time-(index*delay))


however the Y Rotation Delay slider will be used for a time delay in seconds rather than a measurement in degrees for the offset.

Kevin Camp
Art Director
KCPQ, KZJO & KRCW


Return to posts index

Justin Crowell
Re: Staggered layer rotation with min/max
on Jun 25, 2014 at 12:01:22 am

Oh, so you're basically polling the layer at a time earlier than it's currently at? That's a smart way to do it. But does it deal with my max and min issues?

I actually ended up using the following if/then statement:

r = thisComp.layer("Controls").effect("Y Rotation")("Slider") - index*thisComp.layer("Controls").effect("Y Rotation Delay")("Slider")

if (r&lt;0) { r=0; }
else if (r>900) { r=900; }



Editor, Producer, DP
JustinCrowell.com


Return to posts index


Kevin Camp
Re: Staggered layer rotation with min/max
on Jun 25, 2014 at 7:43:56 pm

i had thought about using clamp(), but it wouldn't have allowed the rotation to reach 900.

not that you need to change what you have, but just to show you how clamp() works, rather than the if statements, you could use this:

clamp(r, 0, 900)

Kevin Camp
Art Director
KCPQ, KZJO & KRCW


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2018 CreativeCOW.net All Rights Reserved
[TOP]