Link to Space Invaders: https://meg-h.itch.io/web-invaders
(The game may take a while to start just to give you a warning)
I managed to get through this game pretty easily as I found the scripting fairly straightforward forward and I knew where I wanted to go with the design. The way that I worked was just by creating basic shapes to fill what will become the sprites that I add so I could make the scripting work well and then fix any issues I had after adding sprites.
Scripting
This piece of code I added was simply just to make the ship move. I made sure to add ‘Rigidbody 2D’ to the object which was to add gravity and freeze the Y position and its rotation, this allowed the ship to stay in place but be able to move left and right without any interruptions from collisions or gravity.
Vector3 creates a new vector with given x,y, and z components and allows you to script coordinates for objects.
The if statement is the bullet so when the space bar is pressed a bullet will shoot that can change the fire rate in the sprite script in Unity.

This is the first piece of coding I added and used a coloured square in place of the ship, I found this fairly simple and had no issues with it so I moved on to adding the scripting for the bullets and having the ship be able to shoot them out.

I started with the bullet behaviour which meant that it was able to spawn and move up then moved on to make it able to shoot from the ship by adding Vector3.up allowing it to move. The second part of the script I added after which is to destroy the enemy ship (I added this in after the enemy ship but I screenshotted this afterwards).

This code is for the ship to be able to shoot bullets using the space button.
I added in another coloured square for an enemy and made a simple position movement to move the square down at a normal pace, after this, I made it so that the bullet shot from the ship can collide and destroy the enemy. This makes the clone of what a space invader game is supposed to be like with basic movement and the ability to shoot and destroy enemies.

This is the scripting to be able to shoot and destroy the enemy, after that, there has been a vector3 created so that after it has been destroyed another can spawn randomly on the X axis just above where the game camera is.
I did encounter an issue with being able to destroy enemies at first, I tried reading through the script to see if it is anything that I wrote but everything was completely fine so I had a look at both the enemies and the bullet objects and I found that it was the box collider that was the issue.

The issue I found was that the ‘Is Trigger’ box above was unticked so I ticked it and tested it out and then it was completely fine, I think it might have just been something I missed when adding in the box collider.

The movement for the enemies, which means they can move down at a specific speed which I can change in the sprite script.

One last thing is the bullets that do not hit an enemy need to be destroyed off the map which is what I did here.
Extra code
One extra thing I added in after is the boundaries for the ship object, I didn’t particularly like how the ship didn’t stay in the camera as the speed of it kept making me lose it off the screen. In the tutorial for the top-down shooter, I used the code that was to keep the character on screen for this game as well which definitely made the quality a lot better however the only issue I found with it was slight glitching when the ship hit the sides.

I used Vectors so I could use dimensions of where the play area is to add boundaries where the ship couldn’t leave.

I used Rigidbody and the collision mesh on the ship so I could apply this to the sides of the screen.

I added these to the player movement and cleaned up the code so I knew where it was if I needed to fix it.
Sprites
I decided to make a Windows-inspired space invader using a mouse, the Windows logo and a home page background, this was all made in Illustrator.


Feedback
I got feedback from a couple of people and some of the things they said about the game when I tested it with them are:
- Very sensitive controls, they said that that was really their only issue with the game as it felt a bit frustrating.
- One thing I noticed is that they were engaged but seemed frustrated, however, because they were frustrated they seemed concentrated.
- The shooting was fun.
I think this was interesting as I did feel like the controls were sensitive but because I was used to it I didn’t really think about it. I can easily fix it by changing the speed of the movement of the ship.
How I could develop the game further
If I were to develop the game further I would fix the bug that makes the collisions on the side to stop it from glitching, I would also like to make the movement of the enemies a bit more varied for difficulty, by having some quicker than others and some to potentially shoot back.
What I learned
- How to create and use prefabs
- How to move a player
- How to use Vectors


Leave a Reply