From Prototype to Work of Art

Jared Amlin
May 16 · 4 min read

In my last article, I made a few 2D assets for my game. I can now import them into Unity and replace my 3D primitive assets.

While there are a few ways to import assets into Unity, this is how I like to go about it. I first make a sprites folder, with sub-folders for enemies, player, and weapons, in my project window. I then drop the PNG assets into their respective folders in my Unity project folder, on my hard drive.

When I go back into Unity, those files will now show in the project window, almost ready to import.

With the PNG file selected in the project window, the inspector will show quite a few import options. My PNG assets have a transparent background, so in order to view them properly, the Texture Type needs to be set to Sprite (2D and UI). Hit apply to save the changes.

As seen in the following GIF, bringing assets into the game is as easy as dragging and dropping them from the Project window into the Hierarchy.

My fierce baby Narwhal is now visible in the scene and game views!

After also bringing my weapon and enemy into the hierarchy, I need to take note of some 3D to 2D conversion changes. For starters, the 3D based mesh renderer has been replaced with a sprite renderer.

For the most part, not too much will be changing. There are however, a few items that will need to be addressed when transitioning from 3D assets to 2D sprites. I need to change the Box Colliders on my player, enemy and weapon, to be a Box Collider2D. In this case, I want Unity to use the outline shape of my object as it’s collider, so I will be using a Polygon Collider 2D. I also set Is Trigger to be true, because I want pass-through collisions.

I also need to change the Rigidbody on my enemy to a Rigidbody2D. While the linear drag is similar to the 3D based Rigidbody, the Use Gravity option has changed to Gravity Scale. A scale of zero will keep the game objects from falling off the bottom of the screen with real gravity.

The 2D sprites now need their respective scripts attached. This can be done through the Add Component button in the inspector, or by simply dragging the script from the scripts folder and dropping it directly on a game object.

The data in the inspector that was serialized probably isn’t up to date with what I have currently on my 3D player. That can be fixed by right clicking on the player script component in the inspector, and selecting copy component. Then I can go to the new 2D player sprite script component, right click and paste component values to update it.

Once my components are all reassigned and up to date, I can delete my old 3D PreFabs and drag my new 2D weapon and enemy game objects into the PreFabs folder.

My enemy will need to change the GetComponent for itself, being it’s not looking for 3D components any more. The variables as well as well as void start needs to be updated to reflect 2D Components.

I also need to change OnTriggerEnter, to OnTriggerEnter2D to reflect the 2D collider components I just attached. In the first brackets the “collider” also needs to change to (collider2D other).

My useGravity needs to change to gravity scale and I give it a value of one, being this is causing my little fish to drop off the screen after being hit by a Narwhal tusk.

After saving, I can play test my game with my new assets!

Nerd For Tech

From Confusion to Clarification

Nerd For Tech

NFT is an Educational Media House. Our mission is to bring the invaluable knowledge and experiences of experts from all over the world to the novice. To know more about us, visit https://www.nerdfortech.org/. Don’t forget to check out Ask-NFT, a mentorship ecosystem we’ve started

Jared Amlin

Written by

I am an artist and musician, that is currently diving headfirst into game development with C# and Unity3D.

Nerd For Tech

NFT is an Educational Media House. Our mission is to bring the invaluable knowledge and experiences of experts from all over the world to the novice. To know more about us, visit https://www.nerdfortech.org/. Don’t forget to check out Ask-NFT, a mentorship ecosystem we’ve started

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

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