- Home /
Question by
carlqwe · Nov 22, 2015 at 04:10 PM ·
random.range
Random.Range
Hello i have problem! I newly discovered Random.Range. But when i use it in my code it gives me an error that says: `Random' does not contain a definition for `Range'
here is my code please help! (:
int randomNumber;
void Update ()
{
if (Input.GetKeyDown (KeyCode.R)) {
randomNumber = Random.Range (0, 2);
print (randomNumber);
}
}
Comment
how can that be? I've tried it in 3 diffrent scriptes
Answer by tanoshimi · Nov 22, 2015 at 05:18 PM
I'm betting that you called your script Random.cs? Which means your "Random" class is overriding the definition of the UnityEngine.Random class. Solution? Rename your script.
Your answer
Follow this Question
Related Questions
random issue 2 Answers
How to make enemies spawn in random y position? 1 Answer
NullReferenceException: Help 1 Answer
Display Objects in the center of the screen and add commands 1 Answer
Not repeating random 2 Answers