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

Not all code paths return a value...

$
0
0
I made a script that spawns X amount of asteroids over a certain area. After I made the script an error in the console stated that "not all code returns a value". Here's my script: public GameObject asteroid; public Vector3 spawnValues; public int asteroidCount; // Use this for initialization void Start () { StartCoroutine (SpawnAsteroids ()); } // Update is called once per frame IEnumerator SpawnAsteroids () { while (asteroidCount <= 30) { asteroidCount = asteroidCount + 1; Vector3 spawnPosition = new Vector3 (Random.Range (-spawnValues.x, spawnValues.x), spawnValues.y, spawnValues.z); Quaternion spawnRotation = Quaternion.identity; Instantiate (asteroid, spawnPosition, spawnRotation); } } } Thanks in advance :).

Viewing all articles
Browse latest Browse all 2891

Trending Articles



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