Every time I run:
var number1 = Random.Range(1.0, 5.0);
it always returns 1!!!
I have never set Random.seed so I don’t know what is going on.
Here is the full code (JavaScript):
var number1 = Random.Range(1.0, 5.0);
var question1 = "";
var customGuiStyle : GUIStyle;
function Start()
{
if(number1 == 1.0)
{
question1 = "The symbol for Carbon is...";
}
if(number1 == 2.0)
{
question1 = "The Atomic Number for Helium is...";
}
if(number1 == 3.0)
{
question1 = "The Atomic Number for Nitrogen is...";
}
if(number1 == 4.0)
{
question1 = "How many Nobel Gases are there not considering Ununoctium?";
}
}
function Update()
{
if(number1 == 1.0)
{
if(Input.GetKey(KeyCode.C))
{
Destroy(gameObject);
}
}
if(number1 == 2.0)
{
if(Input.GetKey(KeyCode.Alpha2) || Input.GetKey(KeyCode.Keypad2))
{
Destroy(gameObject);
}
}
if(number1 == 3.0)
{
if(Input.GetKey(KeyCode.Alpha7) || Input.GetKey(KeyCode.Keypad7))
{
Destroy(gameObject);
}
}
if(number1 == 4.0)
{
if(Input.GetKey(KeyCode.Alpha6) || Input.GetKey(KeyCode.Keypad6))
{
Destroy(gameObject);
}
}
}
function OnGUI()
{
GUI.Box(new Rect(Screen.width / 2, 200, 50, 20), question1, customGuiStyle);
}