O'Reilly logo

Unity Android Game Development by Example Beginner's Guide by Thomas Finnegan

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required