2D Game Dev Journey — Day 4: Prototype to Production
Welcome to 2D Game Dev Journey — Day 4: Prototype to production. For today I will touch on the topics of Importing Assets and Packages and how I transformed my 3D assets into 2D.
Starting Point & Setup
Today we will pretty much be starting at the same place we left off in 2D Game Dev Journey — Day 3: Spawn Manager. The only difference you may notice is that I now have a folder called “GameDevHQ”. This is because the assets I will be using going forward, at least for the time being, will be from GameDevHQ’s Filebase system. I have access to these assets due to my apprenticeship with GameDevHQ, but I’ll still go over importing so you all can see how that is done in Unity.
Importing Assets and Packages
Now when it comes to importing assets, whether these assets be audio, sprites, 3D models, animations, etc., there are likely two main ways you will use them to get them into your project — custom assets and packages.
Importing Assets
To import an asset, right-click in the Project window to bring up the drop-down menu and select “Import Asset”. This should bring up your file explorer. Navigate to whatever asset you would like to import and double-click on it to import. You should now see your asset pop-up into your Unity project. I imported an image named beam, which is an asset I created for a past project, as demonstrated below.
Importing Packages
In Unity, you can import packages through the asset store and packages for third-party providers — such as AWS, Google Firebase, etc. I won’t go over this in too much detail for this article, so I refer you to the Unity documentation on packages.
3D to 2D
Placing our Background
As I said earlier, I will be using assets provided to me by GameDevHQ to speed some of the processes up and keep a focus on the software development side of things. As such, the first thing I did was set up my background. The result of me doing so can be seen in the GIF below.
As you can see, our game is already looking a lot more interesting just by adding this static background.
Changing our Player
Up until now, we have been prototyping with 3D objects. To make things 2D, we’ll have to make some changes both to the components we are using and some of our code. Instead of 3D meshes, we will now be using Sprites. My 2D player sprite is a spaceship and I have renamed it to “Player” to take the place of the previous 3D cube I was using. Below is a screenshot of my “Player” setup.
Doing this yields the following result:
As you can see, our projectiles and movement are still working, but our player and enemies won’t collide, even if we do have a 2D box collider on our player. Let’s go to the next section to fix our enemy and player collisions.
Changing our Enemies
To change our 3D enemies to 2D, we follow much of the same steps as we did for our player. Below is the screenshot for how my enemy GameObject now looks in the Inspector:
If we go into play mode with these changes, you will see that things still are not working, and even our projectiles no longer collide with our enemy. This is because, in our code, we have been using OnTriggerEnter() where we now have to be using OnTriggerEnter2D(). After going into my code and making the necessary changes, I got the results I expected as shown below.
We just need to fix our projectiles and have converted everything we have so far to 2D.
Changing our Projectile
Making pretty much all of the same changes as I did for all of my other 3D objects, I was able to convert my 3D projectiles into 2D lasers. Below are the results of changing all of our 3D assets to 2D:
Conclusion
Thanks for checking in and reading today’s article. Tomorrow I’ll be creating a triple-shot powerup, so be on the lookout for that if interested. As always, comments and critiques are welcome. If I have made any mistakes, please let me know so I can correct them for future readers. Also, if you would like a more in-depth tutorial about anything I went over today, let me know and I will take the time to write something up, especially if a bunch of people seem interested.