Skip to main content
4 of 4
added 3 characters in body
H. Pauwelyn
  • 805
  • 5
  • 17
  • 31

What's the difference between UnityEngine.Random and System.Random?

What's the different between this

int randomNumber = UnityEngine.Random.Range(0, 10);

and this

// on top of the class
private System.Random _rnd = new System.Random();

// inside a methode of the same class
int randomNumber = _rnd.Next(0, 10);

I know System.Random must always be initialized on the top of your class what's by UnityEngine.Random is not needed. I know also that System.Random works with a intern "clock" and the "random" number is based on that.

My question is now are there some other difference between UnityEngine.Random and System.Random and witch code is better to use for an Unity project?

H. Pauwelyn
  • 805
  • 5
  • 17
  • 31