Converting from 3D to 2D in Unity

We’ll be converting the 3D greybox primitives such as cubes into 2D sprite assets in this article.

I’ll be using assets from , but you can use whatever sprites you like.

There are plenty to choose from on the Unity asset store, many of which are free!

Essentially we want to replace or modify our player, enemy, and laser prefabs as shown below:

Player Prefab

Enemy Prefab

Laser Prefab

On all of our RigidBody 2D components, we want to make sure Gravity scale is set to 0 so that the Unity physics system does not add speed to our game objects.

We’ve also added a background:

Move and resize your background sprite or image as necessary to make sure it covers the entirety of game screen.

Sorting Layers

We add 2 layers to Unity’s “Sorting Layers” in the Tags and Layers window.

It’s important to note that the order in which we add them matters.
Layers towards the bottom of the list will always show on top of layers above them on the list.

We set our enemy, laser, and player prefabs to the sorting layer of “foreground”.

Naturally, we set the sorting lay on the background to background.

Lastly, there is one bit of code we need to modify on our enemy script.

Enemy Script

Instead of “OnTriggerEnter(Collider other)” we replace this with “OntriggerEnter2D(Collider2D other)”.

Since our prefabs have become 2D game objects with 2D collider triggers, our code has to match.

Our 3D to 2D conversion is complete!

Next time we’ll look into adding special abilities or powerups for our game!




Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Building a website

Frequently used Active Support Methods in Ruby on Rails — Part 2

#CloudDesign: Design changes for migrating from ab on-prem to a Cloud Native world

Learning GitLab CI with Firebase + React: Part 1

Flashing A Mutable Instruments Branches Eurorack Module

ActiveRecord::NotNullViolation when testing with RSpec

Ecommerce API Integration

8 Myths About Software Engineering

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
GameDev Dustin

GameDev Dustin

More from Medium

Adding a health powerup to our prototype

Day 109: Show End Scene

Learn to code by making a 2D space shooter game.

Adding Emissions to Custom Textures