Quantcast
Channel: Questions in topic: "crash"
Viewing all articles
Browse latest Browse all 2383

My while loop seems to crash unity

$
0
0
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.().material.color = Color.green; circleColor = "green"; changeCircleColor = Random.Range(1,2); } if(changeCircleColor == 2) { gameObject.GetComponent.().material.color = Color.red; circleColor = "red"; changeCircleColor = Random.Range(1,2); } } Tnx Adam

Viewing all articles
Browse latest Browse all 2383

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>