- Home /
Random int
how can i generate a random number from an interger?
What do you mean "from an integer"? If you want to generate a random number use Random.Range.
Answer by Seth-Bergman · Jul 27, 2012 at 08:58 PM
var randomInt = Random.Range(0,100);
(will generate an int from 0 to 99) just plug in the appropriate range
note the high end of the range is non-inclusive
http://docs.unity3d.com/Documentation/ScriptReference/Random.Range.html
only on ints, with floats it's inclusive, for the record
and no prob!
Answer by Delarosa456 · Jul 26, 2018 at 05:49 AM
If you are going to create more than one random number, you should keep the Random instance and reuse it. If you create new instances too close in time, they will produce the same series of random numbers as the random generator is seeded from the system clock.
Your answer
Follow this Question
Related Questions
Edit - Code isolation using random ID numbers C# 1 Answer
Convert positive float to negative? 5 Answers
Loop a Function a Random Number of Times 2 Answers
Random Numbers and Array Assignments 3 Answers
pick a random int with the value of 1 from an array 2 Answers