Search Unity

Using unity for 2D mobile games

Discussion in 'General Discussion' started by jackhearts, Jun 2, 2013.

  1. jackhearts

    jackhearts

    Joined:
    Apr 5, 2013
    Posts:
    103
    Hi all, I've been considering switching to unity for a little while and the recent news of the mobile side of things becoming free was great timing. I was just wondering what experience's people have had using it for 2D mobile games such as iso tilemaps, scrollers and the like.

    Are there particular device limitations to using unity for this?

    More than one person has told me that using unity for 2D is like cracking a nut with a sledgehammer but there's not many good quality SDK/engines out there that have all the resources, plugins, etc as unity and can deploy across all those platforms. I believe BB10 and WP8 are in the works as well.

    Is there a lot of unnecessary performance overhead using unity for 2D or is the sledgehammer/nut analogy just superstition? How tricky is it to target multiple platforms in unity?
     
  2. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    given that any engine for mobile runs on 3D accelerated rendering anyway (as there is no 2D rendering), its for sure no sledgehammer situation.

    The only 'drawback' is that it has no 2D tools out of the box, but there are quite a few which enable you to enter the problem from various angles, be it vector based 2D (ragespline) or bitmap. Also there are systems to create 2d skeletal animations straight within unity but nothing prevents you from using skeletal animations created in a 3d modeller of your choice and naturally you could also use bitmap based 2d animations if you wanted too though that would be the most memory costly solution (this is a clear benefit over every focused 2d tech out there, they are all purely sprite based be it corona, cocos, torque2d or game salad).

    Also you naturally get the power and possibility to use 3d objects as background objects or for effects and you can make full use of the shaders and lighting and shadows for your purpose and depending on your license.

    So all in all Unity offers you a lot to create more indepth 2d experiences, the answer you need to answer for yourself is just if you need and can make use of all this or if something simple and lightweight as Corona or Marmalde Quick would be enough for your purpose already without the overhead.
     
  3. jackhearts

    jackhearts

    Joined:
    Apr 5, 2013
    Posts:
    103
    I think because it's a 3D engine they figured it couldn't handle 2D too well, a matter of perspective I guess. I've noticed the asset store has some reasonable resources for 2D stuff and have watched some good youtube vids.

    As you say, there are more possibilities with unity and that's the biggest draw for me although I'd likely need the pro license to take advantage of things like occlusion culling. And having the option of taking a successful game to other platforms is always nice!

    I've actually been using marmalade quick recently but the simulator is a pain to use and it's still missing some features and polish; not bad for a few months old though!
     
  4. Wild-Factor

    Wild-Factor

    Joined:
    Oct 11, 2010
    Posts:
    607
    All big boys use Unity for their 2D game now.
    With some plugins in the asset store you will get the same perf and the fantastic Unity pipeline.
    Unity also support many paltform.

    There is drawback:
    - The physics seams slower (PHysX instead of box2D).
    - The price for each platform in Pro.

    I've made many games for mobile in "pure" java 2D and I've made a game with Unity for ios.
    Once you have your sprite plugin set in place, it's even easier (texture can strech!).
     
  5. jackhearts

    jackhearts

    Joined:
    Apr 5, 2013
    Posts:
    103
    think I might have to put my big boy pants on :D
     
  6. DubiousGames

    DubiousGames

    Joined:
    May 20, 2013
    Posts:
    4
    I prefer creating 2D games in a 3D engine!

    - No real loss in performance or features
    - You can create some nice effects for free by moving / rotating objects through the third dimension
    - Both 3D and 2D assets can be used in 3D, while there are a few extra steps to do this in a purely 2D environment
    - I personally find being able to navigate around different layers of objects in the editor in 3D useful
     
  7. Cure

    Cure

    Joined:
    Mar 11, 2013
    Posts:
    47
    With the right plugins, Unity works great for 2D.

    I have seen some simply awe inspiring 2D games in Unity.
     
  8. jackhearts

    jackhearts

    Joined:
    Apr 5, 2013
    Posts:
    103
    cool, only really downside for me is the cost of pro, which seems to be $1500 x3 for unity standard, android and ios :eek: , and needing to brush up on my C#.

    Will have to double check if I need pro or not
     
  9. kalamona

    kalamona

    Joined:
    Aug 16, 2011
    Posts:
    727
    "which seems to be $1500 x3 for unity standard, android and ios "

    Andoid and ios don't cost 1500 each, much less I think. And I think there is (will be?) a subscribing solution.

    Some of the 2d games made with unity:
    Bad Piggies by Rovio
    Hearthstone by Blizzard
     
    Last edited: Jun 3, 2013
  10. Lukas H

    Lukas H

    Joined:
    Jan 16, 2009
    Posts:
    394
    If you aren't convincent yet, here's a shameless selfpromotion of my upcoming ios game, An Alien with a Magnet, completely 2D in Unity:



    And a timelapse of how its made in the editor:

     
  11. gruddlebug

    gruddlebug

    Joined:
    Mar 11, 2013
    Posts:
    65
  12. jackhearts

    jackhearts

    Joined:
    Apr 5, 2013
    Posts:
    103
    I just checked again and added them to cart and it totalled $4500 or $225 per month, so it must be each. Will have to find a way not to use pro for now.

    @Lucas H - nice looking game, hope it does well.

    @gruddlebug - it's only the basic version that's free
     
  13. Pix10

    Pix10

    Joined:
    Jul 21, 2012
    Posts:
    850
    You won't need occlusion culling for 2D games, unless you're doing something unusual (and so probably not technically 2D anyway). Certainly for Cocos level projects you won't require Pro in a hurry.

    Marmalade's not new incidentally, it's actually a re-branding of an old mobile SDK called Airplay. A lot of developers I know get forced into using it (by publishers mainly), due to it's history I expect - Ideaworks used to have a lot of punch in the mobile space pre-iOS. None of them have anything positive to say about it.

    As for Unity and 2D... Sprites are just openGL quads. Whether you roll your own sprite and mapping APIs or use 3rd party add ons, you'll get just as good results in Unity, with the benefit of a true 3D environment/renderer and all the goodness that comes with that (as Dreamora has already pointed out).
     
  14. jackhearts

    jackhearts

    Joined:
    Apr 5, 2013
    Posts:
    103
    Add me to that list of developers only I chose to use it all by myself, what an idiot I am :p

    What I meant was that quick itself has only been around a few months. I was kind of hoping what I've heard about the C++ side of things would be negated by it's heavy use of cocos2d-x and box2d. On the whole the API's aren't too bad to work with, docs are ok and being able to deploy across all those platforms without installing native SDK's was a big plus. Little did I realise the brilliantly unintuitive way's there software works.

    It's actually quite embarrassing to see some of the 'quirks' and bugs that exist or appear after updates. I've always tried to persevere with whatever software I'm using with the understanding that not everything can be perfect but the marmalade simulator is an unintuitive pile of dog turd ::D

    They need to build a new simulator and deployment tools from scratch just for quick, then I reckon it would be pretty impressive. Never going to happen though, they haven't even got a proper forum. It's a shame because the guys that work there are quite helpful with answering any questions.

    I've really tried to make it work but I've come to the conclusion it needs major love and that ain't coming any time soon, hence the reason for looking at unity. Apart from picking up on my C# most of the other stuff seems to make a lot of sense. I've done bit's and bobs of animating and 3D in the past so it has a familiar feel.


    Also, good to know about occlusion culling. I think I misunderstood it's meaning in relation to 2D so by the sounds of things it shouldn't be needed.
     
  15. deram_scholzara

    deram_scholzara

    Joined:
    Aug 26, 2005
    Posts:
    1,043
    All of Disney's mobile games use Unity, and most are 2D.

    Angry Birds in Space is Unity

    There are many games, and it's practically the industry standard for mobile games these days - so yeah, it's great for this.
     
  16. kdawghomie

    kdawghomie

    Joined:
    Aug 3, 2012
    Posts:
    1
    Not true. The "Where's My?" franchise uses an internal engine, not Unity.
     
  17. zombiegorilla

    zombiegorilla

    Moderator

    Joined:
    May 8, 2012
    Posts:
    9,052
    Not sure where you heard that, but it isn't true. We do have a few games that use Unity, but generally speaking those are the 3D ones. We use a variety of engines/tools for our mobile games, usually whatever fits the needs the best (and often just the choice of the team building them). Most are done using internal engines/tools with the actual tech ranging from html5 to C++ to Java/ObjectiveC to flash. As pointed out, the "Where's My" games use an internal engine.
     
  18. hausmaus

    hausmaus

    Joined:
    Dec 9, 2011
    Posts:
    105
    jackhearts,

    I think you'll find that Unity is very well-suited to 2D game creation. Furthermore, and perhaps more importantly, the development environment itself is fantastic (maybe the best there is), the product is receiving constant, meaningful updates, and the developers are extremely knowledgeable and high-touch. This forum community and the Unity Store development community are excellent resources as well. So right out of the gates, it's a very strong choice.

    You may find that it is helpful to think like a specialized 3D programmer and not a 2D programmer. We just moved from a 3D MMO to a 2D (ish) match&slash project, and what I found when bringing new programmers on is that some of the 2D tasks we're doing actually require more in-depth knowledge than seemingly-sophisticated 3D tasks. This is all knowledge people should have anyway, but Unity doesn't do a lot of hand-holding for 2D assets.

    For an example of what I mean, consider this: Unity does not expose texture bytes in RAM directly. Instead, you work with arrays of structs (Color or Color32), which have relatively expensive getter/setter functions (this is necessary because of how much work is required to make a texture useful under the hood). So the simple task of compositing sprites, if you do it the 2D programmer way, can be slow and fairly awkward.

    The 3D programmer way is to using shaders that either do inline blending of multiple textures via Graphics.Blit(), or the more traditional method of creating a bunch of quads with a simple alpha blending shader and using an orthgorgraphic camera to render the composite you want (all of these methods require the use of a RenderTarget, something you'll be seeing a lot of in 2D).

    Another example would be simple sprites with spritesheets. You simulate these by using quads, which either have their UVs updated periodically to sample a different region of the sheet, or by writing a shader that has a configurable UV rect which you update during runtime.

    Unity's default UI system are, in my opinion, its weakest area and really the only thing I really don't like. However, this highlights a real strength, namely the Asset Store. The NGUI toolkit on the store is a brilliant addon that may be of interest. However, you can write your own easily enough as well. A lot of gameplay interaction details for our current 2D game go way beyond the scope of touch/drag UI components, and they were very simple to implement. Just always be willing to build your own, thinking about things the 3D way, and you should be fine.

    Regarding occlusion and general optimization (batching and such), yes, Unity does offer a lot of convenient features, but there is not much work involved in developing your own. This does get at the question of whether to develop the "traditional" way, where Unity is basically a display library, or the "Unity" way, where code is all contained in autonomous, task-specific component scripts. We are very heavily into the traditional way and having great success.

    I've been in a lot of conversations with people, on forums and in person and even within my company, who seem to think that Unity is a paint-by-numbers prefab assembly tool with only one way to do everything. It does sort of come across that way publicly, and it can be used that way I suppose, but we're finding very few places where we can't go deep enough to do exactly what we want with a very specific application architecture, so I think you can completely ignore any commentary to the effect that it's limiting. It really isn't.

    If you were comfortable with C++ in Marmalade, I don't think C# is going to pose any problems. Except maybe getting used to how civilized it is. Bear in mind that Unity uses Mono, which means you only have access to .NET 2 functionality and a couple extras. This is quite a lot, however, and we've added and ported a number of custom libraries with no problems.

    Meanwhile, I've been using Unity for a while now and am just getting around to looking at Marmalade :). It seems interesting, I plan to do some horrible weekend warrior sludge in it and see how it is in practice. But I would be surprised if I found it preferrable to Unity at this point.

    Good luck!
    Adrian
     
  19. jackhearts

    jackhearts

    Joined:
    Apr 5, 2013
    Posts:
    103
    Thanks Adrian, lot's of useful advice. I was using marmalade quick which is lua based and don't know any C++ but haven't found C# too tricky to pick up. Since the original post I've been learning C# more in-depth and doing bits and bobs in unity to get a feel for it and have to say it's pretty damn good to use. And that's without taking in to account the active forums, asset store and very good documentation. The sooner I can finish current projects and move solely to unity the better!

    As for marmalade I've got one piece of advice, don't bother. If you do decide to punish yourself then just be aware you need the patience of job! It seems unfair to blast them on these forums so won't go in to details but you'll know what I mean if you try it out!

    Anyways, thanks for the advice