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 a space spawn

Our last script will populate our space and will be attached to the player's ship, since it is the center of the game world:

  1. To fill our space with the objects, we need to create another script. Name it SpaceSpawn.
  2. We start it out with two variables. These two define the space within which the new objects will be spawned. They will be created outside the minimum range but within the maximum range.
    public float minRange = 200f;
    public float maxRange = 300f;
  3. Next, we have two variables for controlling the frequency at which objects should be spawned. These will work the same as the ones we used for making the enemy ships shoot at the player.
    public float frequency = 0.3f;
    private float spawnTime = 0;
  4. The final ...

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