Creating spawning points

The basic idea behind a spawning system is that there are special points in which things are spawned. In scrolling games, such as this one, the spawning points are just beyond the visible part of the screen, so the player doesn't see the enemy or the decoration popping out of nowhere.

In Unity, the best things we can use to represent these points are just empty game objects, which we can place just above the camera, as shown in the following screenshot:

Usually, it's hard to see empty game objects, because you need to select them. However, if you click on the icon next to their name in the Inspector, you can choose a label color. As a result, their name appears on the Scene view, and it is easy to identify them. The preceding screenshot shows exactly this process. Also, from there, you can deduce the name. 

As you can see, we have created three spawning points for enemies just above the border of our camera and five spawning points for our decorations that are further away. Because they might be big objects and we want them to appear out of nowhere, you should check that in those points, the object is not visible on the camera.

As a pro-tip, you can move the pivot point of such big objects so that when they are in those positions, they are not visible. As a result, you will be able to use closer spawning points; if not, use the same of the enemies if you wish. 
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset