Spawning different enemy types
Objective: Modify the spawn manager to spawn randomly different enemy types
The first step is to declare a gameobject array to save the different enemy prefabs.
Then we have to go to the Unity editor and assign the prefabs in the inspector.
In the spawn manager I created a function to generate an int related to each enemy type. The function receives an int as a parameter, with different if conditions we check the value of the variable and return another int associated with the enemy type.
In the spawn enemy coroutine I declared an int variable called enemy type and assigned the result of the get enemy index function result and when l called the instantiate function I passed the enemy array with the generated enemy index as a parameter.
And that’s it!!! We can spawn different enemy types.