We’ve upgraded our game from a 3D prototype to a beautiful 2D Space Shooter! Now it’s time to really utilize these assets and get our game looking and feeling like something great!
And what’s an arcade-y Space Shooter without a some fun Powerups!? Let’s get down to business and destroy multiple enemies with our Triple Shot!
We’ve converted our Laser capsules into proper looking Laser Beams. So the first thing in creating our Triple Shot Powerup is the placement of the 3 lasers!
We’ll drag 3 laser prefabs into the Scene Hierarchy and place them as such:
What’s life without a little challenge on your sanity?
Bugs will do that to you.
In this section we’ll clear up all our little bugs and get our game looking, and reacting, fantastically!
Here’s where we left off:
Last time we got as far as our Background, and our game already pops. But to be truly 2D, the rest of our 3D assets have to be converted.
We’ll go through 2 ways to convert 3D GameObjects into 2D. We’ll have some bugs to fix, and that will be the topic of Part 3!
Sometimes, starting from scratch is a much better path to take. Thankfully, there is not much on our Player and it is not very intricate to rebuild in 2D form.
The most important part of our Player right now is the Player Script attached.
We’ve got our game feeling like a game, almost. The functionality is there, and we have a good MVP (minimal viable product) prototype. But the saying goes, you eat with your eyes, and that reigns true in the game world as well.
You don’t need AMAZING AAA graphics that require the latest and greatest GPU’s, but a little pizzazz in the visual quality goes a long way.
In this section we’ll be covering how to change our 3D prototype into a 2D game; converting our Player, Laser, Enemies and background into 2D assets:
Luckily for me, in my GameDevHQ apprenticeship…
We’ve got our Enemies spawning all neat and tidy, but we have a problem — they keep spawning when our Player Cube is destroyed!
To solve this, we’ll have to tell our Spawn Manager to stop spawning when our Player isn’t alive — when the game is over. We’ll create a bool, and communicate with our Spawn Manager from inside our Player script. This will lightly touch Script Communication, which will be discussed quite often as it’s a paramount concept to understand.
The best way to know if the Game is over is to simply create a bool. …
As you saw in the previous article, spawning Enemies is fun, but it gets messy in your Hierarchy if left as is. So it’s best to create an Empty Game Object to contain all the Enemy Spawns, a container if you will.
First, inside our Spawn Manager script, we’ll create the handle to get a reference to our Enemy Container within our code. We’ll link it in the Inspector.
Next we’ll create an Empty Game Object as a child to our Spawn Manager — a logical place to put our container. You could leave it as a separate Game Object…
We’ve created our Enemy, have collision logic, and they can Damage the Player. But what happens after we destroy out enemy? Is the game over? Did we win?!
That wouldn’t be much fun if it was a single enemy, so we’ll have to spawn more of them! It would also be ridiculous to spawn all of them at once, so we’ll be using a Coroutine to implement a Spawn Rate.
For our Spawn Manager, an invisible entity that only manages logic in our game, we’ll create an Empty Game Object and call it Spawn Manager and reset it’s Transform.
Tags are a super helpful system in Unity that makes it easy for us to tell which objects are interacting with each other, and HOW they should interact within our code.
They go hand-in-hand with Triggers, Colliders, and Rigidbodies. Here’s how they work!
Using the Tag system is simple and straightforward. It is giving an Object a tag, or name, to easily reference. Then when an Object interacts with ANY member of that tag classification, it performs an action with EVERY member in the same way.
To give an Object a tag, it is located underneath their Name in the…
Our Player cube can now shoot their Lasers. The lasers get destroyed off-screen, but what is the Player shooting at?! It’s time to create the perfect target — an Enemy cube!
We’ll start by creating another Cube and naming it Enemy. Then create an Enemy material that stands out against the background and Player, and attach it to our new GameObject!
We have our Player cube firing some Lasers, but the problem is that they can fire as many lasers as they can. Seems a little unfair to our Enemies we’ll eventually be spawning.
The best way to counteract this and make the game more challenging is to add a cooldown system for firing a laser!
Adding a cooldown to our Player’s firing mechanism isn’t that difficult, however the concept may be a little hard to wrap your head around at first.
The first concept we need to understand is Time.time.
Time.time is the amount of time, in seconds, that the…