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;
}
↧