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:

  1. We need another new script for this section. Once created, name it SpawnPoint.
  2. 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;
  3. 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;
  4. The third variable is for setting a distance from the player, to prevent ...

Get Unity Android Game Development by Example Beginner's Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.