Adding gun turrets
Creating a gun turret involves creating several objects and scripts. We can't just create the turret object. We also need to create the projectiles that will be fired from the turret, script the projectiles so that they move when spawned, and finally create a script for the turret to spawn the projectiles at regular intervals. Let's start by creating the turret object.
Constructing the gun object
Instead of using an image file for our turrets, as we have previously for the player and level objects, we'll create the turret using a primitive shape:
- Double-click
scene_Level03
in the Project panel to open it TheScene_Level03
can be found in the project included in theChapter07/Start
folder at https://github.com/PacktPublishing/Unity-2020-By-Example-Third-Edition. - Create a new cube object (GameObject | 3D Object | Cube) and name it as
Turret
: - Adjust the object's scale to approximate a gun turret...