Wednesday, November 30, 2011

2D in Unity3D

A lot of people have asked about how exactly I'm doing a 2D game inside Unity3D. So I'm putting all the info into this blog post :D

the Start Menu scene.

So it appears to be 2D, but it's not.

Everything is mostly fixed to one Z depth. Things like the bushes, and clouds appear in the forground and background so the player will move in front and behind them.

Now the Camera isn't running as Isometric, but Perspective with a low FOV:

This is to let the far back and far forward clouds have a perspective and move across the screen at a different pace from the player.

All of the parts you see in the game are textures on a small 2D plane.
Unity didn't have one of these so I had to make one myself:

All the objects I want the player to walk around on have colliders on them.

And anything that moves around has a character controller attached to it. Inside the movement script I lock them to the Z axis each frame, so they don't fall off. 

You may have noticed two colliders on those guys up there... I'm not sure if I need to do that, but it's to detect different types of collisions. I'm really just making this stuff up as I go. Also the player has that extra box collider? That's the Neko Power-Up tail. It stays disabled until you get the Power-Up, it's just a trigger.

As for the player I am doing a cool trick to get his shirt able to change colors.
So there are two planes for him, and they animate in sync.

For the animation,
I load all the frames into the script and set them with:

To make all the pixels nice and crisp,
And in the shader,

And well, that about does it. If anyone has more questions I'd be glad to go into more detail in another post.


  1. that answers all questions I have now, thanks <3

  2. This comment has been removed by the author.

  3. You more than answered my questions here Aion, thanks aplenty!

  4. Thanks a lot for this tutorial, I was looking for something like this. I hope you continue to provide pieces of knowledge like this from time to time :)

    I also found other tutorials that might be useful: