Nerd For Tech
Published in

Nerd For Tech

From 3D Prototype to 2D Assets, Part 3 — Pesky Bugs

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!

Our destined outcome!

Here’s where we left off:

Bug ridden conversion.

I can see 3 problems so far.

  • Our player and other Sprites are BEHIND the background.
  • Our lasers are passing through our enemies
  • and our player is passing through the enemies.

Fixing the sprites BEHIND the background

This is pretty easy to overlook, especially if you are new to 2D workflow. 2D sprites are written/rendered on Sorting Layers, and their Order in that layer.

Like layers of a cake, the icing is seen before the actually cake — the higher layer is seen first, and the higher number order is seen first in that layer.

The Sorting Layer and Order in Layer.

To solve this we’ll create 2 sorting layers; a background and foreground:

Be sure that Background is the topmost layer — this is the farthest back in the scene.

Now everything floats above the background! But nothing interacts with each other :(

Hooray for layers!

Fixing the Player, Laser, and Enemy collisions

When something is passing through another object, this is usually an indication of faulty collision detection. And for us, this is the case — our code needs to be revamped for 2D!

First though, we’ll double check that our Tags are still intact, because they are essential to our Collision detection method:

Fixing our Tags. And I created one for Enemy.

Next we’ll jump into our enemy code.

Previously, with our Collision detection, we were using OnTriggerEnter. But this is now incorrect. We are using a 2D trigger, so we must change our code to resemble that to OnTriggerEnter2D, and Collider2D:

Fixing up the code.

If all went swimmingly, we now have a working game again! Now we can continue implementing features, in the 2d Realm!

Our Bugs took a left on Albuquerque!

Next we’ll be working on creating some PowerUps to make the game a little more interesting!



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
Frank Warman

Frank Warman

Audio Engineer turned Unity Game Dev. Will be combining both my skillsets when appropriate, and will be documenting my Unity Dev growth in these Medium Articles