Search Unity

Which random number generator does Unity use?

Discussion in 'Scripting' started by blobdole, Aug 23, 2012.

  1. blobdole

    blobdole

    Joined:
    Aug 23, 2012
    Posts:
    2
    Pretty simple question. Which random number generator does Unity use for its Random class? I am working on a project and really don't want to implement a 64 bit mersenne twister in java script if I don't have to. =P

    I tried doing some searches but only found answers for how to use the generator, not what was running it on the back end. Anyone happen to know?
     
  2. andeeeee

    andeeeee

    Joined:
    Jul 19, 2005
    Posts:
    8,768
    Hi, welcome to the forum!

    Unity uses Marsaglia's Xorshift 128 algorithm. Check out the Wikipedia page for theory, links and sample code.
     
  3. blobdole

    blobdole

    Joined:
    Aug 23, 2012
    Posts:
    2
    Yay! Not subtractive!

    Thank you very much for the info, it helps me greatly.