ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

# Using slider control to animate the speed/rate of rotation.

FAQ   •   VIEW ALL
 Using slider control to animate the speed/rate of rotation. on May 17, 2012 at 7:26:24 pm

Hi everyone!
This one's got me and my colleagues stymied.
Trying to create an expression (keyframable using a slider control) that will animate the speed of rotation on an object.
The actual rotation value of the object is not as important to me as the RATE of rotation.
I started something using time multiplied by a slider but my quandary is that when I set my slider to zero, I don't want my rotation to go back to zero.
I want it to stop rotating, to hold at that value.
I tried creating some sort of identity switch using a second slider but got nowhere.
Any help would be much appreciated!
-Gabe

 Re: Using slider control to animate the speed/rate of rotation.on May 17, 2012 at 8:28:39 pm

This is the closet thing I have. It's not exactly what you want... but it could be tweaked to do so.

This generates perfect circular motion centered around the original position of the layer. I recommend that you map the radius and
cycle inputs to Expression Control sliders, and the phase input to an Expression Control angle.
Apply this expression to the position of the layer.

cycle = 1; // number of seconds to complete a circle; higher value = slower
if(cycle ==0){cycle = 0.001;} //avoids a “divide by zero” error
phase = 27; // initial angle in degrees from bottom
reverse = 1; // 1 for ccw, -1 for cw
x = Math.sin( reverse * degrees_to_radians(time * 360 / cycle + phase));
y = Math.cos(degrees_to_radians(time * 360 / cycle + phase));