Quantcast
Channel: Questions in topic: "error message"
Viewing all articles
Browse latest Browse all 2891

Field is never assigned to, and will always have its default value 0?

$
0
0
apparently prevSpawnLoca variable has this error. { private float spawnLocaLeft; // left spawning location private float spawnLocaRight; // right spawning location private float prevSpawnLoca; // previous spawn location private float spawnLoca; // final spawn location public GameObject comet; void Start() { StartCoroutine(Spawning()); } IEnumerator Spawning() { while(true) { yield return new WaitForSeconds(Random.Range(0f,2f)); spawnLocaLeft = Random.Range(-8.25f, prevSpawnLoca - 1.6f); spawnLocaRight = Random.Range(prevSpawnLoca + 1.6f, 8.25f); if(Random.value >= 0.5) { spawnLoca = spawnLocaLeft; Debug.Log("left"); } else { spawnLoca = spawnLocaRight; Debug.Log("right"); } var newComet = Instantiate(comet); newComet.transform.position = new Vector3(spawnLoca, 5.7f, 0); spawnLoca = prevSpawnLoca; Debug.Log(prevSpawnLoca); } } }

Viewing all articles
Browse latest Browse all 2891

Trending Articles