Quantcast
Channel: Questions in topic: "loops"
Viewing all articles
Browse latest Browse all 184

While Loop Freezing Unity

$
0
0
What's wrong with this code? Whenever OnMouseDown is called unity freezes. public class createTroops : MonoBehaviour { public stats statsVars; public GameObject prefab; public int incPos = 4; void OnMouseDown() { while (statsVars.units <= statsVars.units + statsVars.units) { Instantiate(prefab, new Vector3(-23.3f, 10 - incPos, 0), Quaternion.identity); statsVars.units++; } if (statsVars.units >= statsVars.units + statsVars.units) { statsVars.units = 0; } } }

Viewing all articles
Browse latest Browse all 184

Trending Articles