It is time to increase the challenge of the game. I will be adding more enemy types, behaviors, and the weapons they use over the next few days… But I wanted to start with something random since all games require a particular random element to make the player extra frustrated, right? - and that is giving them shields!

Objective:

Randomly spawn enemies with an active shield power-up!

Implementation:

First up, we need to create a new Prefab GameObject as a Child to the ‘Enemy’ Prefab - this will be the ‘Enemy Shields,’ which I have decided to set the enemy…


With more and more features being added to the game, the code is starting to look a bit too chaotic. Especially the ‘Player’ script - mainly when trying to play around with the values in the ‘Inspector.

Picture from the mighty Internet - Original source: Unknown..’

Well, it is time to do some organizing and cleaning up certain bits and pieces of the code. I will do this in four ways:

  • Cleaning up unnecessary code and comments - Pretty self-explanatory, but I will also be checking for any unnecessary empty(blank) lines and lousy formatting, as well as any unused namespaces.
  • Removing hardcoded values - These values will be replaced…


Although we created a visualization of the damage for the player some time ago, it is still a bit lacking. Sometimes the player does not even notice that he got hit, and that is where a camera shake comes into play!

Objective:

Implement a “Camera Shake” system whenever the player gets damaged.

Implementation

First up, I have decided that the shake will be moving both the camera and the background image - for that reason, I have created a new empty GameObject, set both objects as children, and created a new ‘CameraShake’ script.


Since, in the previous article, we have limited the player to a fixed amount of lasers that he starts with, we need to give him some way of recharging that - and that is where a new power-up comes in!

Objective:

Add a new collectible power-up to the game, which will refresh the player's ammunition to the maximum. While at it, add another collectible, which will restore the player's life.

Implementation:

First, we need to create prefabs for each collectible - Ammo & Health.


In the previous article, we have buffed the shield power-up to hold three charges. It is only just to add some more limitations to the player. We will do that in the form of a limited ammo supply for the laser.

The demonstration of the Ammo count on the UI.

Objective:

Allow the player to hold a maximum of 15 shots of the laser. If a player runs out of ammunition, play a sound. Update the UI to show the current & maximum ammo of the currently active weapon.

Implementation:

I will start by limiting the player to 15 shots of the laser weapon. For this, I will need…


We already have a shield powerup in the game… but it feels somewhat lacking right now. That’s why today, we are going to take a look at how we could buff it up a little bit!

Objective:

Allow the shield to withstand three hits before collapsing. Visualize current shield strength.

Implementation:

First up, I have decided to visualize the current shield strength with the color of the shield itself. I have decided to go with a blue = full power, purple = damaged, red = almost depleted.

I have created an animation for each color and set each animation as…


Every gamer is familiar with some sprint & stamina mechanics. Today, I will be implementing something similar for the space shooter. A way for the player to speed up his ship for a limited amount of time, and an overheating punishment mechanic if the player uses up all of the “stamina.”

Objective:

Create a limited speed boost mechanic, which, while the ‘SHIFT’ key is being pressed, speeds up the player and simultaneously will deplete the resource bar. Upon the bar depletion, lock this mechanic for a short amount of time.

Pseudo-Code:

  • Check for the ‘SHIFT’ key being pressed in the…


To make our game a little bit more challenging, we need our enemies to have a way to damage us, other than the player ramming into them. And that is where, naturally, more lasers come in!

First up, I have changed the color of the enemy laser Sprite to green using Photoshop. Next, I have created an empty object called ‘Enemy_Laser’ where I have put two laser prefabs, adjusted their transform, and saved it as a prefab.


So, the project, the ‘Space Shooter’ game, has reached an ‘Alpha’ build. For now, the player can play it endlessly, but without much meaning to it. We still only have pretty much only one weapon type, one enemy type that doesn’t even try to hurt us; the whole game is relatively easy - and that is neither challenging nor entertaining.

Original image from the talkingtalent.prosky.co website.

Thus we need to plan out in which direction we want to take the game from here on out. Planning is essential because it helps us achieve the goals that we have set. It allows for more efficient use of…


Now that we have built our application on two different platforms(Desktop - Windows and WebGL), it is time to address the elephant in the room. There is no way to exit the game. The only way to do that was to either close the browser for the WebGL or use a task manager for the desktop build. While this works, it is far from ideal. With that said, it is time to implement the Exit feature!

Original animation by Alfrey Davillahttps://dribbble.com/shots/3020221-Escape-from-Work

I will be utilizing the GameManager and the ‘Escape’ key for this very feature!

All we need to do is to check for…

Matej Marek

Aspiring and eager beginner Unity developer

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