Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions How to animate random property every x seconds with an interval(hold) duration?

  • How to animate random property every x seconds with an interval(hold) duration?

    Posted by Rodolfo Chains on August 7, 2020 at 8:46 pm

    Trying to animate y position at random, whereas the position change every second but the animation from the current y to the next takes half second. So the y stays put for 0.5 sec in between.

    ex:
    – animate y from 12 to 44 during 0.5 sec;
    – stay at 44 for 0.5 sec;
    – animate from 44 to x during 0.5 sec;
    – etc

    Similar to wiggle but adding an interval between each cycle.

    Tried using seedRandom and posterizeTime but it will just snap from value to value, and I’d like it to ease in out and stop for a while. Does that make sense?

    Thanks in advance.

    Rodolfo Chains replied 6 years, 1 month ago 2 Members · 6 Replies
  • 6 Replies
  • Rodolfo Chains

    August 7, 2020 at 9:09 pm

    Basically similar to the code below, but with an animation between values (not just jumping/snapping from one to another) :

    holdTime = .5; //time to hold each position (seconds)
    seed = Math.floor(time/holdTime);
    seedRandom(seed,true);
    random(10, 100);

    OR

    posterizeTime(2); random(10, 100)

  • Filip Vandueren

    August 8, 2020 at 5:20 pm

    Something like this:


    moveTime = 0.5;
    holdTime = 0.5;
    beginTime = 1.5;
    endTime = 5;

    period = moveTime + holdTime;

    t= clamp( time, beginTime, endTime) - beginTime;

    seed = Math.floor (t/period);
    seedRandom(seed, true);
    val1 = random(10,1000);
    seedRandom(seed+1, true);
    val2 = random(10,1000);

    ease( t%period, 0, moveTime, val1, val2 );

  • Rodolfo Chains

    August 8, 2020 at 5:49 pm

    Thanks for that Filip.
    That kinda works.
    I don’t really need the begin/endTime though.
    Not sure how that impacts performance. should I try and remove it from logic or just set the values to suit?

  • Filip Vandueren

    August 8, 2020 at 5:56 pm

    Hi Rodolfo,

    Here’s a version without begin/start-limits


    moveTime = 0.5;
    holdTime = 0.5;

    period = moveTime + holdTime;

    seed = Math.floor (time/period);
    seedRandom(seed, true);
    val1 = random(10,1000);
    seedRandom(seed+1, true);
    val2 = random(10,1000);

    ease( time%period, 0, moveTime, val1, val2 );

  • Rodolfo Chains

    August 8, 2020 at 6:36 pm

    That’s perfect Filip,
    thank a bunch for that!

  • Rodolfo Chains

    August 8, 2020 at 6:42 pm

    Also, I got a very similar answer from Dan Ebberts, in case anyone else is interested:

    segDur = 1;
    minVal = 0;
    maxVal = 100;
    seg = Math.floor(time/segDur);
    seedRandom(seg,true);
    curVal = random(minVal,maxVal)
    seedRandom(seg-1,true);
    prevVal = random(minVal,maxVal);
    t = time%segDur;
    ease(t,0,segDur/2,prevVal,curVal)

    Thanks people!!!

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