Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Bacteria -animating position at fixed intervals with not so fixed values

  • Bacteria -animating position at fixed intervals with not so fixed values

    Posted by Corrado Carlevaro on July 30, 2010 at 2:40 pm

    Hi,
    I need an expression as the one posted in “animating position at fixed intervals with fixed values” but with a bit of randomness in position values: moving a layer about 5 points up, pause for 2 seconds, up again and so on.
    This is the expression Dan wrote:

    moveTime = .3;
    holdTime = 4.7;
    delta = [0,-5];

    seg = Math.floor(time/(moveTime+holdTime));
    t = time % (moveTime+holdTime);
    value + delta*seg + linear(t,holdTime,holdTime+moveTime,0,delta)

    I’d like to add some randomness to the position value (-5), but if I put a random number there (delta=[0,random(-4,-6)]) the randomness is increasing over time and the layer is not fixed during holdTime.

    Any idea?

    thanks in advance
    Corrado Carlevaro

    Corrado Carlevaro replied 15 years, 9 months ago 2 Members · 2 Replies
  • 2 Replies
  • Dan Ebberts

    July 30, 2010 at 3:58 pm

    Try it this way:

    moveTime = .3;
    holdTime = 4.7;
    minDelta = [0,-4];
    maxDelta = [0,-6];

    seg = Math.floor(time/(moveTime+holdTime));
    seedRandom(index,true);
    prevDelta = [0,0];
    for (i = 0; i < seg; i++) prevDelta += random(minDelta,maxDelta);
    delta = random(minDelta,maxDelta);
    t = time % (moveTime+holdTime);
    value + prevDelta + linear(t,holdTime,holdTime+moveTime,0,delta)

    Dan

  • Corrado Carlevaro

    July 31, 2010 at 10:04 am

    Great, and just after one hour!

    Corrado Carlevaro

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