Quantcast
Viewing all articles
Browse latest Browse all 16

Answer by Glister

The code has no errors at first glance. I copied and pasted it looked fine I hit play and your right it literaly crashed unity. I had to force it closed to get out. but on closer inspection you do not have yield in front of waitsecond so I added that and it shines a light on your recursive errors where you have not declared a return type. #pragma strict public var prefab : Transform; var spawnnumber = 1; static var spawnhealth = 50; var spawngap = 20; var numberspawned = 0; //var robot = Transform; function spawnnow ():IEnumerator { Debug.Log("spawnnow"); numberspawned = spawnnumber; if (numberspawned > 0){ Instantiate(prefab, transform.position, transform.rotation); Debug.Log("1 spawned"); yield WaitForSeconds(1); numberspawned = numberspawned - 1; spawnnow(); } if(numberspawned == 0) { spawn(); } } function spawn ():IEnumerator { Debug.Log("spawning"); spawnnow(); yield WaitForSeconds(spawngap); //spawngap = spawngap - 1; spawnnumber = spawnnumber + 1; } function Start () { Debug.Log("started"); yield WaitForSeconds(1); spawn(); }

Viewing all articles
Browse latest Browse all 16

Trending Articles



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