Prototype to Polished Art in Unity

Now that we’ve built out all of the major game mechanics it’s time to switch over to some polished art assets that we have access to (we’ve imported them into our project but not necessarily into our game yet).

It might seem daunting at first but it’s more akin to doing some replace and rewire vs redoing all the work we’ve done so far. Let’s get into it!

First we’ll start off by making sure that we are in the 2D mode in Unity. Next we want to drag in our Background image into our Game scene. We rename it to Space_Background adjust so that it displays to the proper dimension in your game scene. We then create 2 sorting layers. Background and Foreground. This will allow us to quickly place things in the correct layers of the game. In this case we want our Space_Background to be in the…..ya…back ;-P And all our other elements in the foreground. We can also manually assign a sorting number to elements. The higher the number the highest(topist?! not a word) that object is in the layers.

We can no grab one of our Player sprite asset and drag it to the scene. Rename it Player (yup we now have two players). I’m going to adjust its scale to be 0.45 for all three axis. We want to set its Tag to Player and it’s Sorting Layer to Foreground.

Next we want to drag our Player script onto our new Player. This will give our new player all the scripted functionality we had for our cube. Now if we changed any of the values on our old player in the inspector we can easily copy and paste them into our new player via the three dots next to the player script.

Before we delete our old player let’s look at all the components that it has in the inspector. Because we prototyped with 3D objects all these components are made for those objects. But feat not we have the same ones for 2D objects as well. We wont even need all the ones we had for 3D. The only ones we’ll need are RigidBody 2D and Box Collider 2D. We can now delete the old player from the scene.

For the RigidBody 2D it’s important to set the Gravity Scale to 0. For the Box Collider 2D we need to enable the Is Trigger setting. A little play test and we see our new player sprite moving around and firing. But we are not destroying objects or colliding with them yet.

We will do the same thing for our new Enemy Asset as we did above. Since we scripted our Colliders in the Enemy script we need to do a quick update to reflect the change from 3D to 2D by changing the following code;

We’re simply adding 2D to the OnTriggerEnter and Collider

Once our Enemy Prefab is all reset with the above we need to drag the new Updated Enemy Prefab into the Spawn Manager slot in the Inspector.

Finally it’s time to work with the laser. It’s much easier to just work with the new asset so we will start by deleting our existing Laser Prefab. We drag the new Laser asset into our scene. Change its size to 0.25 for all three axis. (make sure both the player and the laser are set to position 0,0,0 when doing the rest fo the steps. Adjust the position of the laser to a position you feel it would look good spawning from (Note the Y-position number). Add a RigidBody 2D and Box Collider 2D (Adjust the attributes as you did for Enemy and Player). Drag the Laser.cs script onto the new Laser. Update it’s Tag to Laser and drag the Laser from the scene to the Prefab folder in your attributes.

Let’s also drag the Laser Prefab to the now empty Laser Prefab slot in the script attribute of the player.

In our Player Script let’s change the offset Y value to the new laser value you noted above. This is in void FireLaser().

We’ll finish up by Editing the Colliders for our Player, Enemy and Laser Objects. Bring them in so they are the same size as the objects.

We did it! We successfully transition from Prototype assets to nice real game looking assets. Great Job!

--

--

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
Games Woods

Games Woods

35 Followers

Unity Developer — Technology Leader — Making Unity Game Development Look Easy