FORUMS: list search recent posts

This rotation expression, but with slider control?

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Bas v Breugel
This rotation expression, but with slider control?
on Aug 19, 2015 at 11:57:27 am
Last Edited By Bas v Breugel on Aug 20, 2015 at 2:03:32 pm

Hi guys,

Is it possible to have this expression below, powered by an slider control?
So if you would set the slider control to 1, it turns every second, if you would change the slider to 4, it would turn 4 times as fast.

(I have a sort of abstract clock ticking, but at a specific moment I want the clock to turn faster)

Expression rotate faster a second from Loepzuiver on Vimeo.



wholeSecond = Math.floor(time);
rotateDuration = 0.2;
anglePerSecond = 6; // 360 / 60
startAngle = wholeSecond * anglePerSecond;

linear(time, wholeSecond + 0.8, wholeSecond + 1, startAngle, startAngle + anglePerSecond)


Return to posts index

Kalle Kannisto
Re: This rotation expression, but with slider control?
on Aug 19, 2015 at 4:24:26 pm

Should work if you pick whip the slider to the beginning of the last line (before "linear")and add a multiplication "*" in between.


Return to posts index

Bas v Breugel
Re: This rotation expression, but with slider control?
on Aug 20, 2015 at 1:00:53 pm

Hmm, the slider works with 1, but wen set to 4, the rotation goes 4 times more rotation degrees instead of 4 times same rotation in one second.


Return to posts index


Kalle Kannisto
Re: This rotation expression, but with slider control?
on Aug 20, 2015 at 1:47:02 pm

Ok, I see the problem. Try putting the slider reference and "*" right before "time" inside the parenthesis.


Return to posts index

Bas v Breugel
Re: This rotation expression, but with slider control?
on Aug 20, 2015 at 2:01:29 pm
Last Edited By Bas v Breugel on Aug 20, 2015 at 2:02:18 pm

Thanks Kalle, but it doenst seem to have any effect.
See https://vimeo.com/136826287 where I recorded my screen. thanks so much for you help sofar.


Return to posts index

Kalle Kannisto
Re: This rotation expression, but with slider control?
on Aug 21, 2015 at 6:26:59 am

Ok, so much for trying to do it without actually trying to see if it works...

After actually trying it, it is definitely more complicated than I thought. Since the rotation is tied to the Time value, it gets tricky to do what you want with the current method. It would be better to animate the slider to represent time. If you use Time, you will have to sample all previous frames for what the slider value was and add them all up. While it can be done, it is inefficient.

So, if you use the slider to represent time, the following does it:

t = effect("Slider Control")("Slider");
wholeSecond = Math.floor(t);
rotateDuration = 0.2;
anglePerSecond = 6; // 360 / 60
startAngle = wholeSecond * anglePerSecond;

linear(t, wholeSecond + 0.8, wholeSecond + 1, startAngle, startAngle + anglePerSecond)


Unfortunately, you'll have to track the time usage yourself if done this way. For instance, if you wan to speed up between seconds 5 and 6, the keyframed slider values would be:

0 seconds: 0
5 seconds: 5
6 seconds: 9 (time advances 4 seconds within 1 second)
10 seconds: 13


Return to posts index



Kalle Kannisto
Re: This rotation expression, but with slider control?
on Aug 21, 2015 at 6:51:31 am
Last Edited By Kalle Kannisto on Aug 21, 2015 at 6:57:21 am

But, if you want to do as you originally planned, this would be the expression. (I named the slider "Speed Control" and it's on the second hand layer.)

frame = thisComp.frameDuration;
current_time=0;
for (i = 0; i <=time; i += frame){
current_time += effect("Speed Control")("Slider").valueAtTime(i)*frame;
}
wholeSecond = Math.floor(current_time);
rotateDuration = 0.2;
anglePerSecond = 6; // 360 / 60
startAngle = wholeSecond * anglePerSecond;

linear(current_time, wholeSecond + 0.8, wholeSecond + 1, startAngle, startAngle + anglePerSecond)


BTW, the "rotateDuration = 0.2;" line doesn't do anything, you can take it out.


Return to posts index

Bas v Breugel
Re: This rotation expression, but with slider control?
on Aug 21, 2015 at 7:40:10 am

Perfect! Kiitos!

It does slow down the render time considerably, but I will let it render overnight :)


Return to posts index

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