An introduction to Unity3D for easy Android game development
Want to create a game for Android? Chances are that it’s a lot simpler than you probably imagine, you just need to find the right tools. Unity3D is just such a tool that gives you access to a professional-grade game engine and streamlines the development process enough to be suitable for complete beginners. In fact, Unity3D is so beginner-friendly that you can create a pretty decent game with barely any coding experience.
Some people will take the stance that using a tool like Unity is ‘cheating’ or that it isn’t ‘proper coding’. But does that really matter? Blockbuster apps like Lara Croft GO, Thomas Was Alone, Shadowgun, Temple Run, Bad Piggies, The Room and even Deus Ex: The Fall were all built using Unity and they’ve gone on to enjoy critical and commercial success. Using Unity is much easier than making a game from scratch or using a more complex engine and as these games show, it really doesn’t limit what’s possible. So why would you make life more difficult for yourself?
What is Unity3D?
If you’re into your indie games, then there’s a good chance you will have heard of Unity already as it’s a favorite among small developers. Essentially, this is a cross-platform 3D engine that is designed to be as user friendly as possible for novices while still being powerful enough for pros.
Blockbuster apps like Lara Croft GO, Thomas Was Alone, Shadowgun, Temple Run, Bad Piggies, The Room and even Deus Ex: The Fall were all built using Unity
A 3D engine of course, is a physics engine that handles the laws and behaviors of various game objects, it also handles the rendering of graphics, lighting and physics like gravity and momentum and may even have some gameplay elements included. If you want to create a 3D engine from scratch, you’ll need to code everything from the way a glass falls off a table down to the way it bounces and refracts light on the way down. Doing the same thing in Unity3D means making a 3D model of a glass, setting its mass and gravity and positioning it on a table in your game world – it’s the difference between a team working for months or one person making a few mouse clicks.
While many other 3D engines exist (such as the Unreal 4 Engine), Unity3D is one of the simplest and has an interface that makes it almost ‘game maker’ like. It also has the advantage of being truly cross platform – you can build a game in Unity3D and then publish it to Android, iOS, Windows, Windows Mobile, MacOS, Linux… even PS4 and Xbox One.
And because Unity lets you incorporate your own code, there’s really no limit to what’s possible. You can even make games that will support VR.
Who Shouldn’t Use Unity?
If you plan on creating a regular mobile game – especially a 3D one – then using Unity makes the best business sense and will be the most fun.
The only times that the limitations of Unity might get in the way, are if you plan on squeezing the very best performance possible out of Android to achieve groundbreaking graphics or if your game has incredibly unique mechanics that are easier to build from scratch.
If the former is true, then you might want to rethink your strategy. Unless you have tons of time on your hands, an unlimited budget and are a coding prodigy you’re not going to be able to compete with the triple A titles. If your game doesn’t really need an engine or is completely unique then sure, you might prefer to build your game from the ground up but you’ll still need some skills to make it happen. And you’d be surprised at just how versatile Unity is – think about how different games like The Room, Lara Croft GO and Deus Ex: The Fall are from one another. As mentioned, you can even make productivity apps with Unity.
Finally, Unity might not be suitable for you if you are completely terrified by the prospect of coding anything yourself. While a lot of the physics and behaviour are already pre-coded (the Rigidbody class takes care of pretty much all physics for instance) you will still occasionally need to add a little C# or Java of your own in order to define some unique behaviors. Most of the information necessary can be found online in tutorials but just to warn you, this isn’t a completely ‘code free’ experience.
The best way to know for sure? Give it a try and see how you get on. Unity is great fun just to play around with, so it’s worth trying out even if you have no aspirations to become a developer.
If I have convinced you that Unity is a great option for your Android game or app, then you may be itching to take the next step.
In that case, you’ll want to head on over to the Unity website where you’ll simply need to click ‘Get Unity 5’ to start downloading.
The great news is that Unity is actually completely free to download. You’ll only need to pay if you want to get the Professional Edition which costs $75 per month and gives you access to some additional features such as the ‘Team License’ for collaborative projects, priority support and the option to customize the Unity splash screen that shows up when your game loads. Once you’ve downloaded Unity, you’ll need to sign up with an account.
If you’re a professional game studio then you’ll probably want to shell out for the Professional Edition. If you’re an indie developer or you’re just planning on having a little play around, then the free version will do just fine. And you can always upgrade later down the line.
Along with Unity 5 itself, you’re also going to need an Android Emulator or a physical device to test your games on. If it’s an action game, then I recommend using a physical device as most emulators are pretty slow. On top of that, you need the Android SDK and JDK – just as you would if you were creating an Android app in Android Studio. These are what will allow Unity to compile and save your game as an Android app; but actually you won’t need them until right at the end.
Something else you’re going to need is Visual Studio, or another environment for coding in C# or Java such as MonoDevelop. This is what you’ll use to edit the scripts in Unity, so when you want to make your character double jump for instance, you’ll click ‘Create New C# Script’ and it will open up the IDE.
Once all this is set up, you’ll be ready to launch Unity and get stuck in…
The Unity UI
If there’s the interest, then in future I can make an article talking you through creating your first simple Android game in Unity discuss how to use the different classes etc. For now though, let’s just quickly look at what everything is and how to make head and tail of the UI.
The Unity Editor is comprised of lots of different windows where you can manipulate assets and view your project. The ‘#Scene’ pane for example shows you your level and all the assets therein. You can use this to pick up sprites or 3D models and move them around, to zoom in or out or to otherwise build your world.
Next to this is the ‘Hierarchy’ window. This gives you a long list of all your assets that are ‘in play’ (i.e. being used in the level or scene). You can thereby quickly find things like sprites, models, audio etc. and highlight them in your scene window.
When you select an item either in the hierarchy or the scene, you’ll then be shown some information about it in the ‘Inspector’. This is where you can set properties, attach scripts or review variables. You can also change the size and the rotation, add a collision detector, set the order it appears in the layer and more.
The ‘Project’ pane meanwhile is where you can see all the files that relate to your project. These aren’t necessarily being used in your current scene but are here ready to be called into action. Essentially, this is a file explorer and if you’re good, your files will be neatly arranged into their correct folders (nope!). Folders of particular interest are the ‘scripts’ folder (which is where you’ll keep the code you write for your assets) and the ‘prefabs’ folder. Prefabs are assets with predefined behaviors, scripts and variables which you can use for quick access. Better yet, when you use an prefab, you can easily make game-wide changes that will be reflected in multiple scenes (levels). This means you could choose to make platforms in your Mario clone 1 pixel wider and this would be instantly reflected in every instance of that game element.
There are a ton of tutorials available and in general the community and support for Unity are two of its strongest features.
The ‘Game’ window is the window where you’ll be able to test your game, the ‘Console’ window is where you’ll see errors and debugging information and the ‘Asset Store’ is where you can buy or download ready-made assets like sprites, particle effects, sounds, scripts and more to add to your game.
Building a Thing
There are more windows of course but these are the ones you’ll use the most and the ones that you’ll see the first time you load Unity up. Try adding a few assets to your scene and hit ‘play’ to see what happens.
When you’re ready to really get stuck in, try following a tutorial to learn the ropes. There are a ton of tutorials available and in general the community and support for Unity are two of its strongest features. Here are two great tutorials you can use for 2D games or 3D games respectively.
If you want to get up and running with some working code even faster though, you can always try out some of the free samples and then do a little reverse-engineering
Unity comes with a ton of ready-made projects to help you start having fun and learning the ropes and these can serve as a useful reference and a way to experiment and see what’s possible. I still recommend working through the tutorials above as well though, as that way you’ll have a better idea of how everything in your project actually works.
To get started with a sample project, you just need to head to the ‘Assets Store’ I mentioned earlier, which you can access through Unity itself. In here you can not only find sprites, scripts and effects to use in your games but also a plethora of fully-working games and sample code.
You can also find the official samples from Unity here if you’d rather download through your browser. A great one to start with is the 2D Game Pack, though there are all kinds of things here for your perusal.
When you’re ready, just click play to try it out in the game window!
Some Words of Advice for the Novice Game Developer
When you first start Unity, you’ll probably find your imagination running wild with all the possibilities. This is an incredibly powerful, simple and easy tool for game and app creation.
But my advice if you’re intending on creating something for release, is to be modest in your ambitions to begin with. Don’t set out to create the next 3D action blockbuster because you’ll be working for years and sinking hundreds of hours of your life into it
For your first project then, consider making something simple and easy that you can complete in a few months. Endless runners work well, as do games with procedurally generated elements as they create much less work for you. Titles like Flappy Bird and Super Hexagon show just how successful a very simple app can be and that way, you’ll be able to enjoy getting reviews and even some profit rather than spending years on something you never manage to complete.
That said though, development isn’t always about the finished product. Give it a go, have some fun and you might just surprise yourself by building something amazing…