From Prototype to Work of Art

Siddhant Thakur
Nerd For Tech
Published in
4 min readApr 6, 2021

--

Now that our basic prototype is up and running it’s about time that we start adding our assets to transform this 3D game about cubes shooting capsules in a black screen to an actual 2D game set in space where the Player fights off hordes of enemies.

3D to 2D :

All assets used in this project are from GamedevHq. Let’s start by adding a sprite (2D images) to our project which will act as a background in our scene. This is as simple as dragging our desired sprite into our Scene View and shaping it the way you want to.

Before you progress any further make sure you have the 2D option toggled on in the scene view, this converts your view into a two dimensional view.

Similarly, add all the assets you’ll need into the scene view. With that done the next part would be to add all our components back into these sprites but with a slight change. Let’s start by adding the components to our Player sprite.

As observed above, we’ve added a Box Collider 2D and a Rigidbody 2D instead of their non 2D versions and since we are working on a 2D game we don’t require a third dimension.

make sure you have it set to zero.

The enemy prefabs and the Laser prefabs also need to be altered to have 2D variants of their components. Make sure they also have their “IsTrigger” toggled ON. We are basically recreating everything we had, exactly the same way but instead of having a three dimensional component they will now have a two dimensional component.

But there’s a catch when converting to 2D, since all our game objects are in 2D we try to fit all our game object in the same plane, this creates a conflicting behavior.

We observe here that our Player game object is being overlapped by the backgorund. But this can be fixed easily by adding a sorting Layer and a order in that particular layer. This will let Unity know which objects to render over which objects.

Selecting a sorting layer made our Player appear in front, but what if we had two objects in the same sorting layer. In that case we can use Order in Layer where the higher values appear in front. For example, let’s have both the background and the player in the same sorting layer,

Now that this is done, lets work on fixing the behavior of our game objects, as if we leave things as it is this is what we’ll get,

This happens because our Trigger functions is checking for a 3D collision instead of a 2D collision. To fix this all we have to do is change our OnTriggerEnter() to OnTriggerEnter2D().

This becomes,

With this we should be ready to go!!!!!!!!!!

Thank you for reading. More to come!!!!!!!!!!!

--

--

Siddhant Thakur
Nerd For Tech

Aspiring Game Developer with experience in the field of Machine Learning.