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 —

Locating, opening and docking 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…


Time for a little re-organization

Following on from my last article on creating a Spawn Manager. You will notice that if you leave the game running for a while without killing any of the spawned enemies the hierarchy will soon fill up.


Sorry… not that Spawn…

Now we have a setup allowing us to shoot some enemies, let’s make it more interesting by allowing them to spawn regularly. A common way to do this is by using a Coroutine in a Spawn Manager script.

A Coroutine is a special kind of method in C# (of type IEnumerator) that allows us to ‘pause’ the running of code by calling the ‘yield’ command. There are several ways to use the yield command to specify different conditions that will trigger the code resume again, for example —

WaitForSeconds(timeInSeconds)

WaitUntil(specifiedCondition)

WaitWhile(specifiedCondition)

To be able to use this in our game…


Script communication can be a tricky concept for newcomers to Unity and C# so let’s look at this in a use case scenario.

If you’ve been following along, you’ll have a Player you can move around the screen and shoot lasers with. Let’s make something to shoot at, I’m just going to make another cube — a little smaller than our player — give it an Enemy tag, colour it red and make sure the collider is set as a Trigger.


Collisions and Triggers

Following on from my last article, we’re going to look at the differences between collisions and triggers and making use of the Unity physics system.

The decision as to whether you want a collision or a trigger is down to the intended purpose of the collider. If you want a physical collision to occur between two GameObjects, then both must be set as non-triggers.


_collider.enabled = false;

Before we look into adding enemies to our game, it’s important to know how the physics system in Unity works so we can easily detect collisions between our different GameObjects.

Unity gives us 2 types of component that are required to be able to make use of the in-built physics system. These are the collider and the rigidbody. It is important to note that both types have 2D and 3D variants.

For example —


In my last article, I went over creating lasers for the Player. The rapid fire aspect could make for a cool powerup but for now, let’s look into implementing a simple rate of fire system.

There are a couple of ways to implement a cooldown system, we’re going to look at using Unity’s Time class to do it — I’ll look at co-routines in another article.

Considering the functionality of the cooldown system —

The Player attempts a shot

If time passed checks out with rate of fire

Allow the shot


Soon into your project, you will realize that you need many of the same GameObject to achieve the look and feel you want for your game — be that enemies, weapon projectiles, birds in the sky or any other often used entity within your game.

Fortunately, we don’t need 100 enemy GameObjects made during design time. With Unity, we are able to create these GameObjects on the fly as and when we need them by using prefabs — or prefabricated GameObjects — and Instantiating instances of them.

Les Street

A UK based Unity Developer with a passion for gaming and coding

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