Posts by "Dario"

How to choose an Android game engine: libGDX vs Unity

Current state of game development for mobile, specifically Android, looks optimistic. A new or an experienced game dev has a handful of options to pick from, ranging from their skill level, project size, game complexity and other factors.

Two different worlds

For easier comparison, I divided tools into two categories. First one are Java frameworks like libGDX (and AndEngine) and second one are complete game engines like Unity (and Unreal Engine). In this article I will compare libGDX and Unity as they are the biggest game making tools for Android platform.

libGDX and Unity are both tools for making a complete game, for sure, but essentially quite different. On the one side we have libGDX, which is a framework and not a game engine. On the other side, there is Unity, which is a game engine. Both of these tools have their benefits and limitations. So, to choose between them you need to determine your requirements.

Like:

  • Which platforms do you want to support – both Unity and LibGDX provide a way to make a game for Android and iOS or desktop
  • 2D or 3D – both tools support 2D and 3D but libGDX is for 2D mainly and Unity for 3D
  • Primarily code or GUI creator – do you want to code in IDE like Android Studio/Eclipse/.. or you want to have a user interface where you can drag and drop objects and write code on the side
  • Programming language – libGDX utilizes Java, Unity utilizes C# or Javascript
  • Pay for professional tools or use open source – libGDX is free, repo on Github while Unity has a free version with some shortcomings and paid full version
  • App size (minimal Unity Android project is about 8MB, while libGDX is about 200kB)

LibGDX

LibGDX is an open source framework maintained by BadLogicGames and contributed by many (at the time of writing this article it currently has 270 contributors on GitHub repo). You can read about history of LibGDX here.

As libGDX is a Java based it is well-suited for Android developers to start building games with. libGDX is cross platform tool so you can make games for Windows, Linux, OS X, HTML, Android and iOS (running Java code in RoboVM). iOS is a bit delicate but I managed to get it working and deploy a game to an iPhone device. Some parts of the engine won’t work on iOS but in my experience they were not detrimental in making a game.

In making a mobile game, you probably won’t target desktops to support your game but there is a nice benefit for developers. If you have spent some time in making apps or games for Android you have found that deploying a build to Android device or emulator can be slow. And I mean painfully slow. Genymotion is a great Android emulator but with libGDX you can deploy your builds to a desktop and debug or iterate your game almost instantly.

Structure of libGDX project 

In libGDX you get complete freedom to do anything as you like. Structure of a game is strictly up to you, for better or worse. If you want to get down to low level, you can always use openGL, as it is exposed and you can manipulate it as you want.

On the other side, numerious APIs which can handle inputs, graphics, audio, networking, assets managing (and others) will solve a lot of technical problems you could run into.

One of the things I like most is how easy is to combine it with native Android code. If you want you can add a libGDX as a view into your game/application and write rest of the code in Android – like networking, ads, Google Play Services and else.

Unity

Unity is a full featured game engine developed by Unity Technologies. It beginnings are somewhere in the early 2000s, started by three programmers. You can find a nice summary of the history of Unity here.

As opposed to libGDX, Unity is a closed source project  which is understandable as licensing Unity is their core business.

But also, being a proprietary software has its ups and downs. All the features can be costly for a small indie studio but even for a decent game a free version of Unity can make wonders too. Positive side is that it’s heavily developed on and the Unity team is constantly adding new features.

GUI editor with drag’n’drop

First difference you will notice when starting Unity is that its main feature is a GUI editor, opposite to libGDX which is mainly code based.

A lot of game making is done by dragging and dropping things, like game objects, interactions between them and other. One creator of Unity said that you could make a game without writing any code. My guess is it would be possible but for adding a bit of complexity to game design, you will need to code some. Languages that you can choose are C# or Javascript.

Free version of Unity will be enough to make a multiplatform game targeting iOS, Android, Windows, OS X and many more (whole list here). Like I written before, Pro version can end up being quite expensive. I wouldn’t worry about getting a Pro version of Unity unless you are quite sure in choosing Unity and have experience with it.

How to choose?

libGDX and Unity are ones of many tools that exist for building mobile games. Like libGDX there are AndEngine, cocos2d-x or PlayN and Alternatives to Unity are Unreal Engine, CryEngine or GameMaker. With simple Google search you could find many more.

My personal rule of thumb is to use libGDX for 2D and Unity for 3D. For mobile games it would be: libGDX for Flappy Bird, Angry Birds or Candy Crush Saga type of games and Unity for Fruit Ninja (orthographic camera with 3D models) or Temple Run-like games.

Conclusion

Both of these tools are here to stay. libGDX is  becoming the biggest framework of its kind and Unity is by far the largest indie game making tool. You can’t go wrong with either of them.

Making a good game is not risked by choosing a wrong engine. They are just a tool for the job. If you didn’t choose an engine you want to develop your game with, try them both out. The best way to find what you like or don’t like is playing around with the tool.

Finishing a game, no matter what the outcome is, is a great feeling. But just an act of building a game can be fulfilling and fun, so choose a game engine that will cater to your needs.

Here is a link to start developing with libGDX: https://github.com/libgdx/libgdx/wiki/Project-Setup-Gradle

or if you want to go the other way, here is a link to download a free version of Unity: http://unity3d.com/unity/download