Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions This rotation expression, but with slider control?

  • This rotation expression, but with slider control?

    Posted by Bas V breugel on August 19, 2015 at 11:57 am

    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)

    Some contents or functionalities here are not available due to your cookie preferences!

    This happens because the functionality/content marked as “Vimeo framework” uses cookies that you choosed to keep disabled. In order to view this content or use this functionality, please enable cookies: click here to open your cookie preferences.

    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)

    Bas V breugel replied 10 years, 8 months ago 2 Members · 7 Replies
  • 7 Replies
  • Kalleheikki Kannisto

    August 19, 2015 at 4:24 pm

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

  • Bas V breugel

    August 20, 2015 at 1:00 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.

  • Kalleheikki Kannisto

    August 20, 2015 at 1:47 pm

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

  • Bas V breugel

    August 20, 2015 at 2:01 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.

  • Kalleheikki Kannisto

    August 21, 2015 at 6:26 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

  • Kalleheikki Kannisto

    August 21, 2015 at 6:51 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.

  • Bas V breugel

    August 21, 2015 at 7:40 am

    Perfect! Kiitos!

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

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