Bone Shooter – Space Invaders Clone
This is the second game I have made in unity, A clone of Space invaders. I themed it around Halloween and named it Bone Shooter. To start making this game, I decided to make concept assets first which turned out to be a big mistake, as I had to make different assets anyway, and my vision changed as the development went on. Next time I am going to make Assets after the game’s mechanics have been programmed.
When it came to coding, I started by dragging in some placeholder boxes for my player, an enemy and a bullet, and added RigidBody components to them and Collision2D to them. I also froze the rotation of the player and its Y value so that it wouldn’t fall due to gravity, and would only move left and right
The first script I made was scr_Player_Behaviour. This script will set the rules for how the player will move in the game.
The script takes the user’s inputs for moving with the arrow keys, and it also sets the shoot button to the space bar, and spawns the bullet into the scene. The line for shooting is slightly more complicated because I added a timer between how long the firing cooldown was. This cooldown is determined by the variable fireRate and the value can be altered in unity to perfect the rate of fire.
To make it so that the bullet would move upwards instead of just being spawned in front of the player, I made a new script called scr_Bullet_Behaviour.
This script starts moving the bullet game object up as soon as it spawns and destroys it if it goes off the screen just to clean up the scene a little, otherwise, the bullet will keep going forever. The bullet also detects if it hits an object with the ‘enemy’ tag, and then destroys the enemy and the bullet and then respawns a new enemy along the top of the screen at a random position using the Random.Range function.
After the bullet script, I made the script called scr_Enemy_Behaviour to tell the enemies what to do, and also to detect when they hit a player.
This script makes the enemy move down by a speed we choose so that it comes towards the player. It also contains collision detection to detect when it comes in contact with a player tagged object, and then restarts the scene due to you being damaged. in my game I have two things tagged as a player to end the game, the skull you play as and shoot with, and a white box behind it out of view that will restart the game if the enemy gets past you
To end the game, I wanted to restart the scene but I didn’t know how to do that so I watched a video on Youtube that showed how to restart the scene by just loading it again using SceneManager.
I also designed the assets at this stage too as I finished the coding. I drew an enemy, a player, a bullet sprite and also a background. these are different from the initial concepts because I decided to not have enemies shoot, so I have the player the bone bullet and I redesigned the enemies into eyes.
Overall I think this game turned out well and I was able to experiment a bit more with unity and its commands. I was able to expand upon the tutorial videos too by using the help I got from the Youtube video on how to restart the scene. Although I think I could add more to it if I went back once I learn a bit more about unity. I think it could have a bit more depth such as different powerups that increase fire speed or the enemy speed increasing when as more get killed.
Bibliography:
Zigurous(2021) How to make Space Invaders in Unity (Complete Tutorial)
Available online https://youtu.be/qWDQgmdUzWI [Video]
[Accessed 14/11/2021]