Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Universal Random Expression

  • Universal Random Expression

    Posted by Filip Stillerska on May 26, 2018 at 7:31 pm

    Is there an expression that meets the following requirements?:

    • Doesn’t require existing keyframes (automatic).
    • Allows me to adjust how many times per second it spits out a new random value (like the first number in the wiggle expression).
    • Allows me to specify the smallest and largest value allowed (for example, a lowest value of -80 and a largest value of 30).

    At first, I thought I would be able to achieve this with a simple wiggle expression, however, it doesn’t allow me to specify the smallest and largest value.

    Filip Stillerska replied 8 years, 2 months ago 3 Members · 5 Replies
  • 5 Replies
  • Dan Ebberts

    May 26, 2018 at 8:33 pm

    Something like this maybe:

    f = 3; // 3 random values per second
    minVal = -80;
    maxVal = 30;
    seed = Math.floor(time*f);
    seedRandom(seed,true);
    random(minVal,maxVal)

    Dan

  • Filip Stillerska

    May 27, 2018 at 10:28 am

    Thank you, Dan, however, I need an expression that generates “smooth transitions” between the values, just like the wiggle expression. In other words, I need an expression that works just like the wiggle expression except I need to be able to specify the largest and smallest value allowed AND how many times per second a new value will be generated.
    Is this possible?

  • Kalleheikki Kannisto

    May 27, 2018 at 1:40 pm

    The same with an eased transition, for one-dimensional properties:

    frequency = 1;
    min= 500;
    max = 250;
    time1 = Math.floor((time-inPoint)*frequency);
    seedRandom(time1, true);
    val1 = random(min, max);
    time2 = Math.floor((time-inPoint)*frequency+1);
    seedRandom(time2, true);
    val2 = random(min, max);
    ease(time, time1, time2, [val1],[val2])

    Kalleheikki Kannisto
    Senior Graphic Designer

  • Filip Stillerska

    May 27, 2018 at 4:44 pm

    Kalleheikki, your expression works great UNTIL I change the frequency because when I do, the smooth transitions no longer works:

  • Filip Stillerska

    May 27, 2018 at 5:12 pm

    I finally found a working expression written by Dan Ebberts in this thread: https://forums.creativecow.net/thread/227/20157

    The expression:

    minVal = -80;
    maxVal = 30;
    w = wiggle(5,1)-value;
    value + linear(w,-1,1,minVal,maxVal)

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