Prospective Unity user, about 2D games?

Hi there guys, new member and first post here. I was just wondering what it’s like to develop 2D games on Unity, because I know it’s primarily a 3D engine. I wanted to make a top down shooter akin to Crimsonland for the iPhone, using animated sprites for graphics, locking movement to x and z axis.

I was intrigued by Unity because the prospect of coding a game from scratch is pretty daunting to me, and I’m going to do a game development degree at university next year so learning C++ myself a year before I get taught it seems rather pointless.

So, how does 2D work on Unity?

Take a look at the 2D platformer example. Unity 2D tools for game dev – evolved for optimal graphics performance

Pretty good indication of what Unity can do in terms of 2D

I saw that, it’s not what I want though because it’s basically 3D with the z axis restricted. I want to know how Unity handles proper 2D.

If you setup the camera correctly it does a great job. I’m putting together what I hope will be a UI tutorial using GUITextures, but it can be directly applied to 2D games. My game happens to be a mix of 2D/3D, but only because I sprinkled some unrestricted particle effects in there. You still have to remember it is a 3D engine in terms of scripting, but once you have your scene ready to go it is pretty easy to script whatever you want. By remember I mean that any manipulation will still have a Z axis. Personally I am using Z to determine draw order, which helps it make more sense.

I’m hoping to have the first version of the tutorial (with assets) done by this weekend, but my kids may have something to say about that :wink:

First off, welcome to the forums.

Second, to do a purely 2D game you’re going to be in for a bit of extra work as it’s possible in Unity, we’re just not set up for it well out of the box. As an example of what you can in fact do, look at Tumbledrop. So doing things in a sprite-based way is in fact doable, but it may prove a bit “clunky” along the way.

Note: as I’ve mentioned elsewhere we’re keen on adding 2D dev features but we’re not prioritizing that for now.

Thanks for the replies, I can’t wait for that tutorial Cedar, could be very helpful.

So a 2D game would basically consist of two flat polygons as a plane, the camera set above it looking vertically downwards, and then the flat sprites on the plane?

I haven’t actually started using Unity yet, installed the trial yesturday and I will probably start learning it tomorrow.

Also, I’ve done iFeathers in Unity, but I already had the license for other projects and I didn’t want to go out and invest in another tool just for one app.

You can either:

(a) Attempt to do it all using UnityGUI (no 3D models at all)

or

(b) Use objects in 3D space but with an orthographic camera looking at them, whether those are flat textured planes or not.

For the iPhone in particular I’d suggest option (b) and avoid the (for now) relatively expensive GUI calls.

Thanks HiggyB that really helped :slight_smile:

Ph4ntom4 yeah I’m pretty new to this; but there are definitely advantages to using a 3d engine like Unity, for 2d game dev. I am working on a dominoes game and technically it’s a 2d game but it looks much better with a perspective camera. And tonight I just realized that my graph layout is much easier if I use a Hinge Joint instead of trying to calculate all the angles. Cheers

Using a 3D engine like Unity to do 2D can have distinct advantages. Besides the built-in physics, etc, you get effects like various blending modes (shaders) and sub-pixel accuracy when rasterizing your sprites. Plus, you can add in a bit of glitz and glamor by doing a bit of 3D here and there just as eye candy and use perspective to make your game feel quasi 3D.

As for Unity in particular… I initially felt that Unity was wholly unsuited to do 2D games on the iPhone since its 3D approach meant that having lots of independently moving sprites would incur a heavy penalty due to draw calls (search the forums for more info on what a draw call is). However, I have recently overcome this limitation and now view Unity as a great solution for 2D as well as 3D. I overcame it by implementing my own sprite manager that is very easy to use and allows a TON of independently moving sprites on-screen while only producing a single draw call. I’m going to make this script available in the next week or so. So keep that in mind if you’re on the fence.

Unity doesn’t have a built-in tile system, etc, so if that’s what you’re after, it will take some extra work. But I have to say it is very easy to work with, which I think would offset most, if not all, of the fact that it is intended as a 3D engine rather than 2D.

I hope that helps.

I’m quite interested to see this. Thanks in advance!

Hmm…are you putting all the sprites onto one giant sheet? Could this be the “mega texturing” revolution for the iphone?
Can’t wait man!
Thanks in advance for the script!
B

Yes, for it to work, you have to have all your sprites drawing from a single material (single texture with a single shader). If it won’t all fit on a texture, then you’ll have to split it out into another SpriteManager, meaning another drawcall. Still, 2 draw calls for a whole bunch of sprites is a small price to pay, especially since you should be able to fit a ton of sprites in a single texture.

Okay, since you’re considering a purchase, and for the sake of the folks at Unity Technologies I don’t want them to have to wait for a purchase, and since I shouldn’t put you in limbo as to whether or not I’ll actually post the code I promised, I went ahead and wrote up some docs and have posted it here:
http://forum.unity3d.com/viewtopic.php?p=116977#116977

You probably won’t get much out of it until you’re using Unity, but at least you know it’s there when you do decide to purchase and that it’s not vaporware. :slight_smile:

Enjoy, and I hope to see you among our ranks soon!

Hi all

I’m a member of a student team from Germany that would like to use unity for our next project. however, due to limited time and resources, we’d like to make it 2d.

Reading through this thread I’m unclear whether the number of draw calls represents a problem on all platforms, or whether this is just a problem on the iphone (which wouldn’t bother us, since we’ll develop for pc and mac).

Can somebody give any tipps or point out relevant changes in unity 3 (this thread ist pretty old…)? Any help or further information on true 2d games in unity 3 would be very much appreciated.