Search Unity

2D game in Unity?

Discussion in 'General Discussion' started by Dranore, May 23, 2007.

  1. Dranore

    Dranore

    Joined:
    May 23, 2007
    Posts:
    57
    I know Unity is primarily designed for 3D games, but how easy would it be to rig Unity for more simple 2D games using 2D sprites/animations and 3D objects? I've just stumbled across Unity while looking for a game engine framework that I can use for prototyping and development, and so far I'm totally sold - I just need to get some idea of how flexible it is. Looking forward to trying it out soon. Thanks in advance.
     
  2. bronxbomber92

    bronxbomber92

    Joined:
    Nov 11, 2006
    Posts:
    888
  3. DaveyJJ

    DaveyJJ

    Joined:
    Mar 24, 2005
    Posts:
    1,558
    Unity isn't restricted to 2D or 3D projects. It may seem that, on first visits, Unity is simply a 3D engine as most of the tutorials and projects being showcased with it focus on that. But this is not the case and Unity can be used for 2D, 3D or whatever else you can come up with. Unity's key strength is the asset management, workflow, ease of use, great developers and community, ability to code in whatever language floats your boat (Javascript, C#, Boo), and "flow." I'm working on creating an online 2D card game in Unity so everything is possible. It's he best game engine I've ever had the pleasure to work with in more than 18 years of computing.
     
  4. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Have a look at this game I did last week, or this game from this week. The latter doesn't use sprites at all, but it could have, since the gameplay is totally 2D. (It does demonstrate the use of an orthogonal camera, though, which the first one doesn't use.)

    Edit: Gee, you can't even wait 2 minutes around here before everyone else replies before you. ;) Anyway, as long as I'm editing, let me add that after those experiences, not only would I say that Unity is suited for 2D, but I'd use it in preference to other 2D engines because of the workflow and physics engine. The only downside I can think of at the moment is that you can't really have pixel-perfect collision detection between sprites, but most of the time you don't need that, I don't think.

    --Eric
     
  5. Dranore

    Dranore

    Joined:
    May 23, 2007
    Posts:
    57
    Thanks for the super quick responses. I can't try the games out in my current locale - but I will when I can. I really appreciate the feedback - if any other users have experience executing 2d concepts in Unity, I'd like to hear their feedback as well. Especially strictly 2D concepts, just for contrast.
     
  6. Marble

    Marble

    Joined:
    Aug 29, 2005
    Posts:
    1,268
    I'm working on a 2D game and it's going great. A little effort needs to go into getting physics working right in 2D, but it's not been a problem for this forever-newbie.
     
  7. David-Helgason

    David-Helgason

    Moderator

    Joined:
    Mar 29, 2005
    Posts:
    1,104
  8. Dranore

    Dranore

    Joined:
    May 23, 2007
    Posts:
    57
    Thanks again. I guess the next step will be to download the demo and give some of the tutorial material a go to get a feel for the environment in practice.
     
  9. NCarter

    NCarter

    Joined:
    Sep 3, 2005
    Posts:
    686
    Here's an example of sprites and tilemaps in Unity. In this case, the game world is really 3D (even though the action mostly takes place on a plane), but the graphics are all 2D. I'm using TextMeshes and custom fonts for both sprites and tilemaps, and I use different letters to index the animation frames and so on.

    For clarity, this is an in-progress remake of my old game, Yoink. The original wasn't made in Unity, but this new version is entirely Unity code.

    Use arrow keys to move around and space to fire. At the moment, everything is indestructible.
     
  10. aaronsullivan

    aaronsullivan

    Joined:
    Nov 10, 2005
    Posts:
    986
    Always enjoyed the game mechanics in Yoink, Neil. Glad to see it being resurrected! :)

    The only downside to working in 2D with Unity is that you'll occasionally have to deal with the added complexity of 3D and do a little foundational prepping to make the 2D more manageable.

    The big upside, of course, is that adding or moving into 3D is going to be cake. :D
     
  11. taumel

    taumel

    Joined:
    Jun 9, 2005
    Posts:
    5,292
    It's cute because it has no filtering...i like it!
     
  12. DaveyJJ

    DaveyJJ

    Joined:
    Mar 24, 2005
    Posts:
    1,558
    That's brilliant, Neil.
     
  13. dingosmoov

    dingosmoov

    Joined:
    Jul 12, 2005
    Posts:
    559
    That looks awesome!! Really, really cool.
     
  14. Omar Rojo

    Omar Rojo

    Joined:
    Jan 4, 2007
    Posts:
    494
    2D is just 3D with one axis set to zero..

    I don't know why people can't see that and have troubles making 2D games in a 3D environment..

    .ORG
     
  15. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    I don't know that anyone's actually had any real trouble...except for that one prospective Unity buyer who ended up deciding it didn't work for 2D, but I'd really like to know what the actual problem was in that case, because I bet I (or anyone with some experience) could have fixed it....

    --Eric
     
  16. pete

    pete

    Joined:
    Jul 21, 2005
    Posts:
    1,647
    it was fixed. they just "didn't want to work that way."
     
  17. Omar Rojo

    Omar Rojo

    Joined:
    Jan 4, 2007
    Posts:
    494
    Practically, there is no pure 2D, like X,Y coordinates, any 2D application need to sort the rendering order of the object so sprites aren't occluded by background or trees aren't shown in the back of a cloud, you need to sort it in some way, and.. wait a minute.. isn't that the third axis ?

    Just with camera orthogonal maybe and no dynamic angles for the view projection.

    I just said that because i have seen people always asking how to do 2D in 3D, not only Unity, but OpenGL, DirectX, and others..


    .ORG
     
  18. aaronsullivan

    aaronsullivan

    Joined:
    Nov 10, 2005
    Posts:
    986
    The other issue is the use of quaternions. There is no reason for them in a 2D system, yet you are forced to deal with their issues when using most 3D engines.

    Plus, a dedicated 2D engine will have a pre-made system that deals with sorting, "sprites", animating textures, transparency, backgrounds and other issues, where using a system like Unity puts some of that on the developer's shoulders.

    Honestly, though, these are tiny obstacles to overcome --this community can help and quickly-- and the benefits of Unity over other systems make it a great one stop solution for any type of game you want to make... except maybe text adventures. (?)

    Sorry, Eric5h5, I know you're probably already giving in to the temptation and we'll see a text adventure with fantastic particle effects in what... 5 hours?
     
  19. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    OK, put this on a GUIText object:

    Code (csharp):
    1.  
    2. function Start () {
    3.     print ("You are in a maze of twisty passages, all alike.");
    4. }
    5.  
    6. function Update () {
    7.     var c : String = Input.inputString;
    8.     if (c == "\n") {ParseText(guiText.text);}
    9.     else {guiText.text += c;}
    10. }
    11.  
    12. function ParseText (line : String) {
    13.     print ("I don't understand \"" + line + "\".");
    14.     guiText.text = "";
    15. }
    16.  
    Sorry...that's the best I could do. :oops:

    --Eric
     
  20. Dranore

    Dranore

    Joined:
    May 23, 2007
    Posts:
    57
    W00t. More replies.

    Yeah. It doesn't sound tooo painful. I *think* I'm going to be getting a Mac Pro - due in no small part to Unity. The only thing I'm waiting on is graphics card upgrades. I'm hoping for new DX10 GFX card support come WWDC as a minor announcement. ::crosses fingers:: Though I'll probably start playing with Unity soon in demo on my mactop - but it's many years old now and not particularly fast. :p