Guns and gun turrets
Let's start tackling weapons in detail. Specifically, the level contains a player and enemy ships. The player must shoot enemies but, right now, cannot do so. See Figure 4.1. On thinking carefully about weapons, we identify three main concepts or things that need development. First, there's the spawner or generator—the object that actually fires ammo in the scene when the fire button is pressed. Second, there's the ammo itself that, once generated, travels through the level on its own. Third, there's the ability for ammo to collide with other objects and damage them.
Tackling each area in order, we begin with turrets—the points where bullets are spawned and fired. For this game, the player will have only one turret, but ideally, the game should support the addition of more, if desired, allowing the player to dual-fire or more! To create the first turret, add a new empty game object to the scene by selecting GameObject | Create Empty from the...