Time for action – creating spawns
The script we will be creating in this section will keep our game world populated with all the enemies our player might want to destroy:
- We need another new script for this section. Once created, name it
- This script begins simply with a few variables. The first variable will hold a reference to our
EnemyTank prefab. We need it so we can spawn duplicates.
public GameObject tankPrefab;
- The second variable tracks the spawned tank. When it is destroyed we will create a new one. Using this variable we prevent the game from becoming overwhelmed with the enemy. There will only be as many tanks as spawn points.
private GameObject currentTank;
- The third variable is for setting a distance from the player, to prevent ...