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

How to spawn enemies on my spawnpoints

$
0
0
Hey so im trying to make my enemies spawn on a random spawnpoint i have but when i try it it spawn at random positions instead of the spawnpoint this is how they spawn and my spawnpoints public GameObject[] spawnPoints; void Start() { spawnPoints = GameObject.FindGameObjectsWithTag("SpawnPoint"); es = SpawnRandomEnemy(); StartCoroutine (es); } WaitForSeconds wait = new WaitForSeconds(spawnInterval); while (currentNumberOfEnemies < maxNumberOfEnemies) { int enemyIndex = Random.Range(0, enemyPrefabs.Length); Vector3 spawnPos = new Vector3(Random.Range(0, spawnPoints.Length), 1); Instantiate(enemyPrefabs[enemyIndex], spawnPos, enemyPrefabs[enemyIndex].transform.rotation); currentNumberOfEnemies++; yield return wait; }

Viewing all articles
Browse latest Browse all 1488

Trending Articles



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