If you’ve been following this thread of articles since the beginning, you’ll be familiar by now with my past as an artist and illustrator has colored my choice of instructional metaphor. And while my palette may seem a bit monochromatic in that regard, I have no choice here: in this article we’ll be talking about art in the literal rather than the metaphorical.
Until now we’ve been working with simple cubes and capsules, and with good reason. Prototyping requires rapid iteration. The choices you make at that early stage can have a big impact on your design choices for UI and art assets. If you jump right into the work of fully rendering your art assets and then start to prototype, you’re going to arrive at a point where choices you made in art will restrict gameplay choices. Either you re-do all that artwork or compromise your vision of the game.
Far better to work out the fundamentals with simple objects first. Which we’ve done! So, let’s look at converting our 2.5D prototype into a 2D sprite-based arcade shooter.
Let’s start by making space look more interesting than a blank black canvas. I’m talking nebulae, pulsars, quasars, globular clusters — the whole 9 light-years. I’ll drag my background image into the scene view and resize it to fit the camera:
Over in the Inspector, I add a couple of sorting layers for Background and Foreground. This list is rendered from top to bottom, so make sure Foreground is below Background to make Foreground render above Background — I know it’s confusing.
Everything else will be added to the Foreground layer, so keep that in mind.
There are a few different ways to convert these 3D objects into 2D sprites. I could create all new objects and add the necessary components, or I could remove the 3D components from my object and replace them. Whichever route you choose, make sure to sketch out a plan so you don’t miss anything.
Here’s a quick checklist for our shooter.
All 2D objects should have:
☐ Sprite renderer and a sprite, with Sorting Layer set to Foreground
☐ Transform scale set to an appropriate size, with position on the z-axis at 0
☐ A 2D collider (Box 2D, Circle 2D, etc.) with Is Trigger enabled
☐ A 2D rigidbody (all except Player), with Gravity Scale set to 0
☐ A script (Player, Laser, Enemy) with all Game Object references attached
☐ A tag (Player, Laser, Enemy)
When you’ve done all that make sure to apply overrides or make new prefabs and discard the old ones. Give one last check to all the Game Objects (including the Spawn_Manager) and make sure their script references aren’t empty.
Let’s see that game:
Looks great. But there’s still a lot of work ahead. In the next article we’ll add some interest to the gameplay with our first new feature: a weapon powerup. I’ll take the opportunity to talk about animating sprites in Unity.