My latest update to my space shooter game is an enemy that has random movement. This was rather a simple thing to implement and the code below pretty much explains it all.

The ZigzagEnemy method is on my Enemy script and takes a float variable that is a random number between 0–100 that is changed in the coroutine every second. This random number will determine if the enemy moves down, left, or right. One thing I learned is to be careful when calling a random number on update because it might not behave how you would expect.

Here is what they look like!

So a while back, I added Thrusters to the player. While these thrusters work, there is nothing visually to show the player that they are using the thruster besides the fact that they sped up. Two things were added to solve this problem: A thruster bar UI element and activating/deactivating the visual thrusters depending if the thrusters are being used. For the visual thrusters, I just used SetActive in the correct places and that's all. But for the UI bar, I will go into a little more detail.

The first thing is to make an empty game object (Thruster_UI) that…

With the addition of the drone shot power-up, my game now has 6 power-ups. Some are more powerful than others, so I wanted to make a system that makes some power-ups rarer than others. These are the powerups and their rarity: Ammo and speed are common, triple shot and shield are rare, and Drone Shot and extra life are very rare.

To implement this, I added a method in the SpawnManager script called DoesPowerUpSpawn().

This method takes an int which will represent a power-up. If you recall, the power-ups are in an array, and this powerUp argument is the index…

As previously mentioned in my last article, I created a new weapon type called a Drone Shot. This weapon type can not miss! It will find the location of the nearest enemy and track it down until it is destroyed. This weapon also does not consume ammo because it is not a laser, but a mini version of the player ship. Here is what it looks like:

I learned a lot creating this feature, especially how physics and math can be used to create a behavior. …

The next thing new feature to my game is supposed to be a new weapon type. As I was thinking about what to do, I realized that my Player script was handling what weapon was being used. I feel handling what weapon is being used is outside of the scope of the Player script and I figured it would be easier and more organized for future me if I had a script dedicated to weapon logic.

The first thing I did was make an empty game object that is the child of the Player named “Weapon_Manager” and reset the location…

Adding a camera shake when the player gets hit is another great way to visualize that the ship getting hurt and immerse the player further. I wanted variety in my camera shakes and after some research Cinemachine seemed like the best approach.

Cinemachine can be downloaded from the Package Manager. The first thing to do after downloading Cinemachine is to add a CinemachineBrain component to the Main Camera. This in simple terms chooses which Cinemachine virtual camera controls the Main Camera.

Now it is time to create a Cinemachine virtual camera. This is done just like any other game object…

I recently added shield strength to my Space Shooter game. The shield powerup can now take three hits before it is destroyed. Each time the shield is hit, it’s alpha is decreased which makes the shield appear weaker.

The way the shield visualizer functionality was originally set up was when the player was hit (LoseLife() method), there would be a check to see if the shield was active. If it was active, the player wouldn’t lose a life and the shield would disappear using SetActive(false). …

Player Ammo

The first thing I thought of when it came to ammo was a UI display to let the player know how many shots they have. So I started with creating a text object on my canvas that would then be accessed in my UIManager script. Here I created a public function named UpdateAmmo(int ammo) which updates the UI Ammo display to “Ammo: int ammo” as seen below.

The if check is for the triple shot, where 3 lasers are used. For instance, if the player as an ammo count of 1 then uses a triple shot, the ammo count would…

I finally finished the Space Shooter 2D course videos which has been guiding me through this game. Before I begin the “Phase 1: Framework”, where I start to implement features on my own, I wanted to show off what the game looks like now!

VFX and Post Processing

My game now has explosions, thrusters, and damage visualizers for the player which makes the game a lot more immersive. There were also some post processing effects added that makes the game for visually appealing and stylized.

Sound Effects

Now, I can’t really demonstrate how the SFX sounds, but it also makes the game a lot more immersive…

When you build a Unity application that is played in a fullscreen mode, there has to be a way to quit the application. If this is not implemented, people that use this application will only be able to quit the application through the task manager.

Luckily, this is very simple to implement:

This snippet of code was put into the Update method of my GameManager. With this code, I will be able to leave my game by hitting the escape key when it is built!

End of a short GDJ 16!

Brett Blandford

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store