Random.Range (153594)

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);
		}
	}

This works perfectly fine, when i try it, in Unity...

–

1 Answer

1

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.