Last time we added the behavior of our first powerup. Now its time to add something visual to it and a way to activate it. This will be in the form of a collectible that the player will pick up.

Objective: Create a powerup sprite that will activate Triple Shot when it is collected by the player.

To start let’s drag the sprite we want to use to represent the powerup from the Assets folder to hierarchy so it can become a new object. This is what mine will look like:

So we got our spaceship, it can shoot lasers, and when we have a powerup activated, it will shoot three at once!

Then when we test it out, we might see something like this:

If you look closely, the lasers are just slightly off from where they need to be, even though we positioned them right when we created the prefab.

Or it could be more noticeable like this:

It’s time to add some powerups to the game! They come in handy when you might be swarmed with enemies and the single laser won’t cut it on its own. It also brings a player more satisfaction when playing by getting that boost of power!

Objective: Create a prefab for a triple-shot powerup and instantiate it.

For now we won’t worry about the collectable that would activate it, let’s just focus on the power up itself.

First, we’ll want to create an empty object, name it “Triple_shot”, and copy three lasers into it as children.

When we place a box collider on an object, sometimes it doesn’t get placed in the exact spot where contact should be made. To fix this, go to the object you want to change and press this button in the box collider component:

Now in the scene view, you should be able to manipulate the box like so:

Why do we prototype? Why shouldn’t we just get into adding all the cool sprites and pretty assets while we build the game?

Well it would end up creating a lot more work for us.

A prototype, alongside a game design document, is basically a blueprint. It will show how everything works together in structure. If we skip this step and start mashing everything together without a plan, then every time something goes wrong, we might have to redesign many visual elements.

A prototype let’s us test the game and make sure it works. Once that is done we can start adding visuals that will specifically compliment the mechanics.

We left off last time deleting gameobjects and attaching our scripts to sprites in order to add some art to the game. Well, this also ended up making everything not work…

Fear not! All we have to do is make some adjustments and everything will be hunky-dory. So let’s fix it!

Objective: Convert enemy and laser to 2D and fix the scripts to communicate properly once again.

We will begin by deleting components.

Yup, on our laser and enemy prefabs, all of our current components are useless except for the one holding our script. …

A game that is just cubes shooting pellets at other cubes isn’t very interesting. There’s no hook, and no visual appeal.

Think about it, would you rather play a game like this:

Or something like this:

We can spawn enemies every five seconds, and we can keep them organized in the hierarchy, now its time to add a way to stop the spawning when there is no player around to shoot them. We’ll be having to work more with GetComponent, and more specifically, GameObject.Find.

First, we need to create a global bool variable that’s false. In my article about creating the spawn system this was _stopSpawning. This is the condition in the while loop that keeps the loop going as long as it is false.

Next, in the script for SpawnManager, we need to create a…

With the Spawn Manager set up, if we keep letting enemies instantiate without destroying them they will eventually take up a lot of room in the hierarchy. We’ll want to minimize the clutter if that happens.

To do this, we’ll want to create an empty object within the SpawnManager object in the hierarchy. Name it “Enemy Container”.

The next step in making this game is to spawn more enemies in the game to shoot. Right now the enemy will only go back to the top of the screen if it hasn’t been destroyed, but once we destroy it we have no enemies. So let’s make something to we keep having something to shoot.

First we’ll need to make an empty object.

I already created the Spawn Manager, but that is what you should name the empty object. Now make a script for it, and open it up.

We’ll be making a Coroutine, and for that we will…

Sabrina Windsor

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