If you have not played tank arena download it for free from the games section of this website, the game is a 2D wave shooter in which you much destroy as many enemy tanks as possible to beat your high score, however, there are no health refills so once you take damage you keep it.
Tank arena has a relatively simple design, it is a wave spawning game in which the player must destroy as many enemy tanks as possible in order to earn points and beat there or a friend's high score. It's designed to be played by a single player who will have to overcome wave after wave of enemy tanks that will damage and eventually destroy the player, which creates a loop or cycle of gameplay with the player being able to play another game of quite at the end of the round.
The Game Build
Unity game engine was used to build and develop the game, the game consisted of one scene with a predetermined starting location for the player (Indicated by the tank sprite).
The 2D game assets were all developed using Adobe Photoshop then imported into unity. This sprite sheet was then divided up into the relevant sections needed for the individual graphics as shown in the image below.
The game has around 11 scripts in total each controlling an individual aspect of the game whilst communicating or holding data for each other. In this section, I will explain how a few of these scripts work.
The camera controller script makes use of mathf.smoothDamp. This allows the camera to changes its direction gradually over time creating a drag effect, the target location is the player position in this case, which is continuously updating using the void FixedUpdate method.
The Effects script controls how long the explosion mark sprite remains in the game space before being deleted. The script uses a simple if statement to calculate the amount of time remaining. The script also fades out the explosion mark using the objects alpha channel as shown in the image on the left.
Explosion Effect Script
This script makes use of the Destroy method which can either be used to destroy a particular object instantly or be used with a float value that acts as a count down timer before the method is called. Note that because this is a prefabricated game object, the keywords are used "This.gameObject" to ensure that it destroys this instance of the explosion effect in the scene.
The game manager script controls aspect of gameplay that relate to the stopping and starting of the game as well as keeping track and storing any changes to the high score. This script also controls the loading of menus such as start and quit game menu. The script makes use of unity game engines playerprefs which help create external files for storage of high scores.
The enemy tank script works based on a line of sight. The tank itself consists of two main parts, the tank turret and the tank shell. The tank turret tracks the players' position as soon as it is spawned into the scene, hence the turrets will always be looking towards the player. The movement of the tank is controlled by the tank shell, this works by detecting if the player is within a certain range. Depending on the range the enemy tank will either move towards the player who may be about the leave the enemy attack range or move away from the player if they get to close to the enemy tank. If the player is able to hide behind one of the blocks in the game then the enemy tank will no longer have a positive line of sight on the player and therefor will stop moving and stop firing. The script makes use of raycasting to achieve some of the effects.
The Player Controller
The tank controller has two parts similar to the enemy tanks. the turret game object tracks the mouse position, which is then converted into a screen point using Camera.WorldToScreenPoint. The tank body or shell makes use of the horizontal and vertical input keys to control and rotate towards the direction of movement.