Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Changing speed of time based value

  • Changing speed of time based value

    Posted by John Toi on August 15, 2010 at 6:19 pm

    Hi again!

    I have this expression

    life = 5;
    offset = 0;
    SeedRandom(index,true); 
    pause = random(life+offset);
    if(time < pause)
    age = 0;
    else
    age = (time-pause) % life;

    The variable \\\”age\\\” pauses at 0, increases, resets back to 0 when it reaches the life value and repeats the same thing again.

    As you can see, this is a time based expression and although the value keeps increasing, the speed is constant after the pause. I want to control the speed within the expression so it will gradually slows down as the value increases and the speed will reset and repeat as the value loops back.

    However, I cannot get the speed to gradually stop. Subtracting time does not work as the speed stays constant and only slow it down altogether. The linear method only allows me to change the speed but not gradually.

    Is there a way to gradually change it and if so, how?

    Thanks in advance!

    John Toi replied 16 years ago 2 Members · 3 Replies
  • 3 Replies
  • Dan Ebberts

    August 15, 2010 at 7:34 pm

    It’s hard to tell what you’re trying to do exactly, but maybe this will help:


    life = 5;
    offset = 0;
    seedRandom(index,true);
    pause = random(life+offset);
    if(time < pause)
    age = 0;
    else
    age = easeOut((time-pause) % life,0,life,0,life);

    Dan

  • John Toi

    August 17, 2010 at 8:14 am

    Thanks for the reply.
    From what I understand, the easeOut() function interpolates the values like the linear function and adds an ease to each end. However, i was trying to get the speed to constantly decrease as the value increases from 0 to the value of the life variable and then to repeat the same thing as the value resets to 0.

    Thanks again

  • John Toi

    August 26, 2010 at 7:57 pm

    Nevermind, solved it.
    life = 5; // life
    offset = 0; // pause offset
    res = 5; // resistance

    seedRandom(index,true);
    pause = random(life+offset);
    if(time < pause)
    age = 0;
    else
    age = (time-pause) % life;
    x = age*age;
    linear(x,0,(life*life),0,res);

    Based on the fact that squaring time increases the speed.

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