Menu

2D Game Development in Unity3D: Overview

Unity3D’s GUI class (previous post)

Pros:

  • Very fast to use: only line of code is enough to display an image – no other actions or setup involved.
  • Images can be displayed in a ‘pixel-perfect’ way.
Cons:

  • Bad performance on iOS: not suitable for if more than 30-50 have to be simultaneously visible on screen (each image consumes one draw call).
  • Using the physics engine is not possible without a workaround.
  • Additional code is required to support different screen resolutions.

Sprite manager systems like GUISpriteUI (previous post)

Pros:

  • Fast on iOS: textures can be easily combined into texture Atlases, potentially resulting in only one draw call.
  • Images can be displayed in a ‘pixel-perfect’ way.
  • Most systems allow positioning sprites in the editor.
Cons:

  • Slower to use: more code writing and setup involved.
  • Using the physics engine is not possible without a workaround.
  • Depending on the system used, additional code may be required to support different screen resolutions.

3D objects and orthographic projection (previous post)

Pros:

  • Allows using the Unity3D editor to build your levels.
  • Relatively fast UI on iOS and Android.
  • Easy access to the physics engine.
  • Easy to combine with other Unity3D features (e.g. particle effects, 3D animated characters and animation blending, …).
  • Your game automatically works under different screen resolutions.
Cons:

  • Performance can be optimized on iOS by using texture atlases, but requires additional setup.
  • Using pixel coordinates to define the scale and position of objects is possible, but makes it a lot harder (or impossible) to get decent results from the physics engine.

As you can see, each of them has its own specific advantages and disadvantages. This means there is no ‘best’ method; all depends on the needs of your project.

7 thoughts on “2D Game Development in Unity3D: Overview”

  1. Equinox says:

    If you wanted to create an mmo supporting 64ish player at ones, would the 3d object, using unitys default build mode, with just an orthographic projection be viable?

  2. Yes, I would heavily recommend to do so. The same optimizations as you’d use for a 3D MMO with this amount of players would be used when you’d want a 2D look.

    One of these optimizations could be to share textures as much as possible, by creating texture atlases (which requires custom plane meshes – could be created at runtime – so they can have different UVs, each referring to their part in a texture atlas).

  3. BlazeFaia says:

    What about making a 2D fast paced action oriented platformer/shooter with probably 16 bit sprites? Which would be my best choice?

  4. In this case, I would also recommend the third method.

    One important point not mentioned above is that the coordinates used for your graphics are in screen space for the first two methods, while the coordinates for the third method are in world space.

    In general, if you want to be able to create your game levels manually in the Unity editor (rather than randomly generated in code from example), or if you have a moving camera, the third method would make your life easier.

  5. Meanwhile, GUISpriteUI evolved into GUISpriteUI – an open source project by prime31.

    However, GUISpriteUI has been surpassed by other systems, such as EZ GUI and NGUI. NGUI is generally considered to be the better one, and is actually quite a bit cheaper at the time of writing ($95 vs $200).

    At Heyworks, they made an interesting comparative study between EZ GUI and NGUI. Their blog post can be read here.

  6. Ian Bradley says:

    Hey which one you recommended for a game like Metal Slug or Mercenary Kings?

  7. Hi Ian, I know this answer comes a bit late, but for the other readers:

    For 2d platformer I’d recommend the new 2D system (added to Unity since Unity 4.3) for the game graphics, and NGUI (which is basically a sprite manager system) for the UI.

    We’ll update this post somewhere in the future to take Unity’s new 2D system into account, as we’ve experimented with it for a project recently.

Leave a comment

Your email address will not be published. Required fields are marked *