Spawn game objects from array to array of transforms
Hey guys! I need help in instantiating objects in a transform. Currently, what I want to do is when an enemy dies, it will spawn new enemies (which are in an array) in "fixed" positions (also in an array).
Eventually, what I want to happen is that enemy 1 will spawn at position 1, enemy 2 at position 2, and so on. I suppose I could go with:
GameObject enemy1 = Instantiate(SpawnedEnemies[1], SpawnLocations[1].position, SpawnLocations[1].rotation);
GameObject enemy2 = Instantiate(SpawnedEnemies[2], SpawnLocations[2].position, SpawnLocations[2].rotation);
GameObject enemy3 = Instantiate(SpawnedEnemies[3], SpawnLocations[3].position, SpawnLocations[3].rotation);
// and so on...
...but then, apart from it being expensive to run, there won't be any flexibility in doing this.
Anyway, any and all help will be appreciated.
Your answer
![](https://koobas.hobune.stream/wayback/20220612212927im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Detect when edge of the map is in camera view and dont random spawn enemy inside of it 0 Answers
How do I make the enemies continue spawning? 1 Answer
IEnumerator project problem 0 Answers
how to Spawning a single enemy, respawn when object not active? 1 Answer
Can I spawn with an array in order? 2 Answers