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:
- To fill our space with the objects, we need to create another script. Name it
SpaceSpawn
. - 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;
- 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;
- The final ...
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.