Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Random number within a range and hold it

  • Random number within a range and hold it

    Posted by Hat-rack on August 7, 2007 at 4:32 pm

    Hi,

    I’ve been able to get a random number from 0-1000 using:

    wiggle(0,1000);

    This generates the number and it stays the same over the whole time line. Now I need to get a random number from 1000-2000. How can I accomplish this with wiggle or is there a different method? I tried:

    random(1000,2000);

    but this generates a random number for every frame that plays.

    Thanks!

    Matthias Stoll replied 5 years, 3 months ago 6 Members · 6 Replies
  • 6 Replies
  • Dan Ebberts

    August 7, 2007 at 5:49 pm

    This should do it:

    seedRandom(index,true);
    random(1000,2000);

    Dan

  • Harry Davidson

    February 26, 2018 at 12:33 pm

    Thanks Dan!

  • Patricio Veloso

    March 21, 2018 at 12:06 pm

    Thanks Dan for your invaluable support to the AE community woldwide.
    Hugs!

  • Victor Pérez

    January 23, 2020 at 10:59 pm

    Dear Dan,

    I´m using the expression you suggested to get a random number between 1 and 5.
    Yet I´d like to have this expression to be re-evaluated so I can end up with a different value the next time I open the after effects project.

    Eg. let´s say the 1st time I open the file its value is 3 and if I load the file again the value changes (within the range of course)

    seedRandom(index,true);
    random(1,5);

  • Dan Ebberts

    January 24, 2020 at 1:22 am

    I can’t think of anything an expression could access that would be unique for each AE launch. You do get that automatically with scripting though, so I guess you could have a simple script populate a slider with a random number and use that as the random seed for your expression, but you’d have to remember to run the script each time you launch AE.

    Dan

  • Matthias Stoll

    January 24, 2020 at 8:49 am

    Talking about randoms, this is only a little bit related… I’ve been wondering about it quite a while now. In a project I had about 50 dots and I needed to connect with lines them in a “Plexus”-like fashion, but only some dots needed to connect.

    I used random expressions to target 2 dot-layers giving the coordinates for start and ending of every line (shape layers). Of course some of the results were equal, and I had to manually eliminate those double lines – because I could not think of another way.

    So my question: Can I somehow save results from a random expression and then exclude them from the range of the next one? All random expressions would need to connect to another expression doing this.

    This should be possible, any ideas out there?

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