Quantcast
Channel: Questions in topic: "enemy"
Viewing all articles
Browse latest Browse all 1488

Random Spawn timer

$
0
0
So I am trying to spawn random enemy objects at a semi random interval. The questions and answers on here are way more complicated than the code I have landed on. Here is what I am using: void enemyspawn(){ enemyposition = new Vector3 (Random.Range (-15, 15), -13f, 1f); GameObject enemyone = Instantiate (enemyonePrefab, enemyposition, Quaternion.identity) as GameObject; enemyone.transform.parent = transform; Invoke("enemyspawn", Random.Range (spawnmin, spawnmax)); } This seems to do exactly what I want it to do. I call it once from the Start() function and it spawns my object in the random(ish) location. Am I missing something? Will there be unintended consequences with nesting like this? I think I am set but I am doubting myself at this point. Thanks

Viewing all articles
Browse latest Browse all 1488

Trending Articles



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