- Home /
This question was
closed May 25, 2013 at 05:36 AM by
robertbu for the following reason:
Duplicate Question
Question by
Red Sentinel · May 25, 2013 at 05:16 AM ·
javascriptrandomnumbergenerator
Randomly generated number
Hi everyone. I've been having problems trying to randomly generate a number between 1 and 10. I'm not sure if there's a specific way to do it in unity, so I thought I would ask the community. Thanks for any input.
Comment
You can use Random.Range(). For integers, the top of the range is exclusive (not included), so if you want a number between 1 and 10 including 1 and 10 you would do:
var i = Random.Range(1,11);
Note this question has been answered many times in various ways on this list:
http://answers.unity3d.com/questions/308513/random-number-generator.html