With our game progressing nicely, it’s about time to start adding some flare to it. Shooting enemies is all well and good but they certainly shouldn’t just blink out of existence!
For this, similarly to our powerup animations, you will need some sprites for your explosion animation. Filebase is an incredible resource for such game assets!
Drag your first explosion sprite onto your hierarchy to create a new GameObject, then set up the animation for it — a reminder of how to animate sprites in Unity can be found here.
So let’s say our Player was unfortunate and just got a Game Over screen. What next? Our game doesn’t know what to do but I’m sure it’s a possibility that the Player may want another go at it.
To create the ability to restart the game if we get a Game Over, firstly we need a new UI GameObject with a Text component.
One of the main challenges with the any game is to progress as far as possible — what makes this a challenge? The chance to not progress further of course…
Introducing a gaming staple — the Game Over screen! Following on from my last article on UI building, we need to be able to notify the Player when they fail and lose all of their lives.
With Unity, it is easy to create great looking UI for displaying useful information to the Player. However, computers are kinda dumb and they don’t know about any of the elements of a game that many would take for granted.
We need to tell our game what it means to take damage, lose lives or even what a score is. Thankfully, that is also fairly easy to accomplish. What is a life or score? Well, to us developers, they are simply variables…
When trying to trigger certain code based on the contents of a certain variable in C#, an If/Else If statement is a quick and easy way to achieve this — as demonstrated in my last article
However, as the potential options increase, the code can quickly become difficult and confusing to read. Requiring us to add a whole new condition comparison for each new item, for example —
In a previous article, I went through the steps involved in creating a powerup for our Player’s weapon systems. It was, however, a very inefficient method due to it not being very flexible or adaptable. By this, I mean that we would need to create a new script for each new powerup we create.
In this article, I’m going to look at modifying our existing scripts to enable us to create new powerups for the Player without the need for any new scripts. …
To avoid having our in game sprites looking boring and static, Unity allows us to easily animate them.
We can do this through the Animation window —
With the GameObject we want to animate selected, we can create a new animation from the animation window. Find or create an appropriate location within your project’s file structure for the animation and give it a name.
With our game out of the prototype phase, it’s time to look into giving the Player something to help them out — enter the Powerup!
Let’s start with a temporary improvement to the Player’s weapons —using the sprites in the 2D Space Shooter assets from Filebase, we have the sprites for a Triple Shot powerup so let’s create the new weapon upgrade.
Using the existing Laser prefab, we can create a cool new weapon that fits the name of our powerup nicely and make a new prefab of this.
Once we have the basic concepts of our game in place and functioning, we can look at moving away from the Unity primitives and getting some assets into our game.
I’ll be using assets from the awesome Filebase that you can find here.
Firstly, with the project I’ve been building over the previous articles intended to be a 2D shooter, we first need to switch from 3D design mode to 2D design mode.
From there, we can change from the default Unity skybox to a solid color background and bring in a backdrop for our game — ensure that the…