HI,
My code seems to crash unity I suspect its the while loop not being able to end any suggestions.
#pragma strict
var changeCircleColor : int = 1;
var circleColor : String;
var gameState : String;
function Start ()
{
Debug.Log("The game has started");
gameState = "play";
}
function Update ()
{
while (gameState == "play")
{
ChangeCircleColor();
if(Input.GetKeyDown(KeyCode.Space))
{
gameState == "stop";
}
}
}
function ChangeCircleColor ()
{
if(changeCircleColor == 1)
{
gameObject.GetComponent.<Renderer>().material.color = Color.green;
circleColor = "green";
changeCircleColor = Random.Range(1,2);
}
if(changeCircleColor == 2)
{
gameObject.GetComponent.<Renderer>().material.color = Color.red;
circleColor = "red";
changeCircleColor = Random.Range(1,2);
}
}
Tnx Adam