TANK! TANK!: Unity3D Tank Game
• Mobile Game Design Course Project.
• #Unity3D
The scene is full of various dessert models. Players can move or shoot these desserts by operating the tank. Some of the desserts will change their material color because of the bullets involved. The area with the aperture on the ground is the minefield. When the player moves the tank, it may be blown up by landmines or switched to the start screen to replay.
DESIGN
In order to create two UI Buttons, I first added a canvas at the background of the scene. The Canvas is a rectangular area that displays the UI components, and the UI component must be a sub-object for it to function. UI components determine the sequence in which they appear in the order in which they appear in the hierarchy, with the latter components overwriting the previous components. In the image below, the order of Image2 in the hierarchy appears later. So, if the two areas overlap each other, Image2 will overwrite the Image.
Game start screen
There are three render modes for the Canvas component: Screen Space – Overlay, Screen Space – Camera and World Space. In this project, I chose to use Screen Space – Overlay which is the most common mode that can draw the UI on top of the results produced by Camera. The UI component will cover all the objects in the scene and the Canvas is not affected by any objects/settings.
Then I inserted several UI Button components in the scene. The Button component can accept the player’s button click event. When the click is generated, the OnClick event is emitted immediately. Clicking will occur when the mouse/touch is released. Press the + sign in the OnClick event list and add the target object to select the script and Function to receive the event. I wrote the script of the switching scene to the OnClick event on two of the buttons and named them “START” and “EXIT” respectively.
Figure 1. The picture above shows the start scene of the tank game and its two UI buttons.
Another eight arrow buttons were used to control the up and down rotation of the barrel, the left and right rotation of the barrel base, the left and right rotation of the tank body and the back and forth movement of the tank. To switch the camera perspective from third-person to first-person perspective, simply click the earth-shaped button. If the sky is too dark to see clearly, players can turn on the headlights of the tank. If players want to emit a bullet prefab, they can press the bomb button.