Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Are Unity 2D games actually 3D games?

Discussion in '2D' started by me12, Sep 6, 2014.

  1. me12

    me12

    Joined:
    Oct 10, 2013
    Posts:
    3
    Hi guys,

    I am completely new to Unity, yet I want to develop a 2D mobile game.

    After watching a few videos I am a bit confused. It looks like you create a regular 3D game and just set the camera to orthographic to make it look like a 2D game.

    Is this actually the way you develop 2D games in Unity? I mean that sounds like a lot of wasted resources if you have all models and stuff in 3D where simple 2D images (sprites) would do.

    Probably these guys are just doing it wrong?

    Any clarity would help.

    Thank you!
     
  2. Pyrian

    Pyrian

    Joined:
    Mar 27, 2014
    Posts:
    301
    Yes and no.

    Unity is a 3D engine and runs as such behind the scenes. You can fairly easily add 3D assets to otherwise 2D Unity games.

    However, 2D development is not 3D development left orthographic. You don't need meshes, there's a whole different physics engine. You can just make Sprites out of images and move them around with scripts, animation, and 2D physics, and there you go.
     
  3. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,398
    Absolutely everything in Unity is 3D...even if you don't explicitly use models from 3D apps, all sprites and so on are meshes made out of polygons. You can see this in the scene view particularly if you have wireframe mode turned on. (FYI, there's no requirement to set the camera to orthographic for a 2D game. In fact it can be quite advantageous to leave it as perspective, e.g. making a 2D game with parallax scrolling backgrounds is dead easy with a perspective camera, since you just put the layers on different z distances and let the camera take care of the rest.) The "2D" mode in the editor is just a camera perspective, and everything including sprites can be manipulated in 3D mode as well.

    --Eric
     
  4. GarBenjamin

    GarBenjamin

    Joined:
    Dec 26, 2013
    Posts:
    7,441
    I know where you are coming from. I was used to always working with bitmaps and such and blitting images to buffers and presenting the buffer to the screen.

    But then I got into Direct3D several years back and dabbled in 3D. One of the things the D3D API had was Sprites. Basically, a sprite was simply a Texture that I believe was rendered on a quad.

    These days graphics cards are all 3D so it is not wasteful in a performance sense. Actually the cards may not even have onboard 2D blitters these days. I am not sure. But they do have very optimized 3D rendering systems.

    These 3D cards are not even breaking a sweat drawing thousands of sprites or shouldn't at least. It depends on how many different textures / materials and such you are using. On the other hand, you could have one very detailed very high geometry 3D model with multiple textures that could bring the card to a crawl.

    From what I can see Unity3D follows the same principles I learned working with Direct3D. You want to batch your sprite drawing calls around textures. Each call requires loading the texture over to the graphics card. Just pack as much onto one texture (image) as you can without getting ridiculous with the size. Doing 2D via 3D has a whole different set of factors for performance than true 2D but for the most part you should have no performance issues.
     
  5. me12

    me12

    Joined:
    Oct 10, 2013
    Posts:
    3
    Well, thank you everyone.

    I guess I will just use sprites then and ignore these tutorials where people are using actual 3D models.
     
  6. GarBenjamin

    GarBenjamin

    Joined:
    Dec 26, 2013
    Posts:
    7,441
    Those examples are probably for some kind of 2.5D games. Where they are using 3D models but the view is locked in an orthographic mode (or perhaps even perspective but still only viewed from a fixed angle).

    You can basically do it as you like. If you want to use 3D models only you can. If you want to use Sprites only you can. If you want to use a mixture of the two you can do that as well.
     
  7. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,398
    Or they were for Unity versions before 4.3, since sprites didn't exist until then.

    --Eric