From Prototype to Work of Art in Unity!

Objective: To transform our primitive assets into a work of art using Sprites in Unity!

Now that we have a good portion of the game mechanics setup, it is time to add some life to our project by converting our primitive assets into Sprites.

Importing Assets

To start with make sure to import your assets into your project, and we are going to start with adding a background to our game. If you are unsure how to do this, there are a few ways. The first is to simply drag and drop the files into the Project window in Unity. Alternatively, you can right click in the Project window and click ‘Import New Asset’ or ‘Import Package’ depending on what you are trying to import.

Importing assets

The other way is to go to the ‘Assets’ tab at the top and click on this to receive a drop down menu:

Assets importing

Adding a Background To Our Scene

Next, we are going to simply drag and drop our sprite background into our Hierarchy and you should now see it in the Scene view.

Drag and drop your background sprite into the Hierarchy

If you drag your background in and the sizing looks all funny, before you start adjusting transform settings and manipulating objects to fix this, head on over to this link and have a quick read, it should save you some time!

Adding Our Player and Enemy to the Scene

Now that we have our background it is time to drag in our Player, Enemy and Laser sprites. This will be a 2D Galaxy Shooter game so we are going to have to replace some components that existed on the original primitive Player, Enemy and Laser prefabs so make sure that the game starts to register 2D Collisions and Triggers.

New Player sprite Inspector

You will notice that the only components that the new game objects have is a Sprite Renderer so we need to make sure that we add all the existing components from our primitive assets but with ONE big change!

Change Box Collider to Box Collider 2D

We need to change the Box Colliders and the Rigidbodies to 2D!

If you see this + symbol next to your components it means that you haven’t saved your changes to your prefab:

Unsaved changes to the prefab

Make sure to “Override” your changes to your prefab:

Override or ‘Save’ changes to your prefab
Saved prefab changes
  1. On the Player, we need to replace the “Box Collider” with “Box Collider 2D”, and also add the ‘Player’ script.
  2. On the Enemy game object we need to replace the “Box Collider” with “Box Collider 2D” also and the “Rigidbody” to “Rigidbody 2D”, and add the ‘Enemy’ script.
  3. And lastly, on the Laser we also need to replace the “Box Collider” with “Box Collider 2D”, and add the ‘Laser’ script.

Script Changes

Lastly! We need to make sure that we make the necessary adjustments to our scripts to allow for 2D Collisions and not 3D.

On the Enemy script make the following simple changes:

Enemy script changes

Few Extra Things!

Don’t forget to add the Tags back to your objects.

Have a look at the Box Colliders to make sure they are the appropriate size.

Also make sure one of the Box Colliders has ‘Is Trigger’ ticked.

The object that has the Rigidbody on it, switched to Kinematic and not Dynamic.

Hit ‘Play’! Hopefully if all has gone smoothly, you have now transitioned your game from having primitive 3D assets to 2D sprites!!

Note: Ignore the dark colours of the game I need to play around with some Post Processing and make some changes to the Player and Enemy sprites.

--

--

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