Creating Android games with Unity
I’ve had a lot of requests for tutorials on game creation for the Android based phones and tablets. This will be my first (but not last!) tutorial.
I have two, 20 minute videos that take you through the process of creating a simple flight game.
You will need the Unity engine to follow along (http://unity3d.com). While the Android version of the software is expensive, you can do everything with the basic free version except publish to the actual device.
In part 1, I cover general setup and needed software to be able to publish to android devices. I also cover the first steps in setting up a game environment including skybox, and player.
In part 2, I cover the creation of the asteroids, bullets, prefabs, and use pre-existing scripts to add player control. I also cover the publish to the android device.
I would note that while this process was specific to publishing to an Android phone, everything would work exactly the same (minus the publishing) for an iPhone or iPad.
Here are some of the assets (Scripts, Rock and background)
Note: The scripts used in the demonstration are all available from the StarTrooper example on the Unity site: http://unity3d.com/support/resources/tutorials/iphone-multiplayer-tutorial

I need this source Unity, you can share it???? Thank you very much
You can download the free version of Unity from http://unity3d.com. The free version will not allow you to publish to a mobile device, but it will allow you to get started with developing for mobile devices.
if i publish to android market can i play it?
I’m not sure I understand your question. If you publish a game to the android market, you do get to play it. But no, you don’t have permission to publish the game that I demonstrate to any market.
what i mean is….because im using unity basic and i cant test a game on my android phone but can i upload it to android market…download it then test it.m
I don’t think that would work. You need to be able to publish for android from Unity. Without the basic Android, you wouldn’t be able to publish in the right format so that it could be uploaded to any of the android markets.
I need resource of this tutorial: psd sky, rock, texture, scene, …
Can you share it? Thanks.
I have added a link to some of the materials used in the project: star background and the asteroid.
I have a question
Which engine that game company use most to develop 3D game for android?
Does it have a free engine for android ?
There is no clear cut engine that game companies are using for 3D game development on the Android at this time. The operating system and the ability to do 3D games are still new enough that there is no top or most popular engine to use. That being said, I do like Unity (Unity3D.com)and Corona (ANSCAMOBILE.COM) for my development projects. For a no-cost engine, the only project that I’m aware of is the Cocos2D project.
Thank you. But Cocos2D is just for 2D, is it right?
Correct. Of course, you can do amazing things with 2D, but your project should dictate the tool (engine) you select.
Good Morning
Great tutorial, and you are too kind to share your knowledge, I been using and learning Unity around six months but only for web and PC standalone projects, I want to learn how to use the touch properties, accelerometer and that stuff of an android phone in order to port some of my demos to the android platform, Can you share the code you use in your spaceship?
Sorry my poor english, is not my native language
Thanks in advance, Alex
I’ve added the scripts to the download. Enjoy!
Good Night!
Where is the spaceship?
thanks
Sorry my poor english, is not my native language
Thanks in advance
Thank for your tutorial but I got some problem when I build & run on Andriod emulator This’s error masage:
Resource re-package Failed!
package -v -f -m -J gen -M AndroidManifest.xml -S “res” -I “android.jar” -F bin/resources.ap_
Locale/Vendor pairs:
/
/
Files:
drawable\app_icon.png
Can you fix it? help me please
Thank so much
I have the same error.
Resource re-package Failed!
package -v -f -m -J gen -M AndroidManifest.xml -S “res” -I “android.jar” -F bin/resources.ap_
Locale/Vendor pairs:
/
/
Files:
drawable\app_icon.png
This is usually caused by a missing resource file. If you examine your error list you should see where it failed to process one of the files(should be at the bottom of the list). Which editor are you using? It might be that your editor (such as eclipse) has the file stored in a different directory and you just need to copy the file into your Assets/Plugins/Android folder.
I am a noob trying first time to build for android as a test. I too get the same error…But i cant make your solution to work
Where is Assets/Plugins/Android folder?, In your video also ‘materials’,'scripts’,'Standard Assets (Mobile) are only shown.I am not using eclipse or any editors..
Update Unity.
3.3 are fixed this problem.
thank you for this wonderful tutorial,i have been following this step by step with Unity open trying to follow carefully what you say.However i can not go any further because there is no starfighter in your package. i would like to really learn this stuff but now im hung up, cause you please re-upload the missing star fighter files?
I have updated the zip file to include the ship and it’s textures.
thank you for the files,this really aided me in understanding more. it is so very hard to find tutorials on unity android stuff so keep up the good work. i hit a problem, i am using unity 3.2 and i got some errors, when trying to build and run before adding the scripts like you show the very first time i get this error and my phone reboots.
“Warning! Using more than 1 pixel lights on a mobile device may decrease performance severely. You can change the mobile quality settings in ‘Project Settings -> Quality Settings’.”
i thought that could be related to a bad driver install or related to HTC’s software so i went ahead and just moved the apk to the phone and it worked like in the video.then when i added the scripts i got this error,
“Assets/Scripts/PlayerControls.js(18,32): BCW0012: WARNING: ‘UnityEngine.iPhoneSettings.screenOrientation’ is obsolete. screenOrientation property is deprecated. Please use Screen.orientation instead.” and another one
“Assets/Scripts/PlayerControls.js(23,32): BCW0012: WARNING: ‘UnityEngine.iPhoneSettings.screenOrientation’ is obsolete. screenOrientation property is deprecated. Please use Screen.orientation instead.”
i look forward to any advice and future tutorials,thanks again.
Uhh, this tutorial just stops after part 2, you dont actually show how to get he ship flying around/shooting bullets/ect.. unless im missing somthing?
also, all the iphoneTouch had to be replaced with just touch
@Natious, I ended up doing a second set of Unity videos on general game development on same concept. The bullet pre-fab is covered in those tutorials. Code would be the same for web or mobile deployment.
Thank you so much Doc’ for this tutorial. You explain so nice, everything becomes easy
Please keep going the great work !
Hi Dr. Burton, great work.
Please add scripts for download.
there is no any scripts in archive..
Hi,
your fantastic job with this tutorial and lots of patience to teach beginners. Keep it up. I am asking that you put the scripts of their example, because we can not continue without them. Can you send or post on the site for download
thanks
Okay. I hear you! You want the scripts! All of the scripts are from the StarTrooper demonstration on the Unity website. I have posted the link to the resource at the bottom of the article.
Hi
The tutorials are really helpful. But i was thinking if you have any such tutorials for Augmented Reality Apps in android on unity .
If you have any knowledge kindly mail it to me that would be really helpful
That is a great idea. I will work on putting something together over the summer.
HEy starfighter 02 texture is missing i think,it doesnt make that package shape so i cant apply the textures..kindly look the file?
oh i figured out i need to have 3d max installed as well..between my bscs final year project is a 2d game android..Can u help me where to start will be great
You need to completely design the game on paper. I always tell my students that if it isn’t fun on paper, it won’t be fun anywhere else. After you have it designed, break it into it’s components and you should see what objects and functions you need to design.
Thanks i am clear with my design but people are telling me to learn andengine library and create a game there.Can u tell me weather unity3d will be good or angengine?.Its just a simple 2d game i have to submit in my uni where a person shoots the helicopter with a high score
Yes, you COULD use the andengine library (and the price is right). You COULD use unity3d, but that would be like using a canon when all you need is a BB gun.
Personally, if I needed to crank out a quick 2D game for an Android phone, I would use Corona by Ansca Mobile. The trial is free and it will allow you to deploy it to an Android phone. If you want the full version, they are offering a special deal to students for just $50.
can u tell me whats the difference between full and trial version?
i already have unity 3d.
The trial (or basic) version is a full version of Unity that will allow you to publish to web, pc, or mac. It is for those who make less than $100K per year. The Pro version has additional features, and does not require a Unity splash screen and is required if you make more than $100K from your game per year.
No matter which version of Unity that you use, you will have to add on iOS or Android to publish to mobile devices. There is a basic and pro version of iOS & Android, with the basic costing (at this time) $400. You can check the Unity3d.com website for more information on licensing.
we have followed the complete tutorial and have added all the scripts required but my asteroid and bullet are not moving. actually no motion is there , can u tell me wats the problem . i have checked the kinematics option in all rigidbodies.
Without seeing your project, there isn’t any way I can tell. I would suggest that you watch my tutorial on creating a web-based game in Unity where I cover the scripts for shooting and movement: http://www.burtonsmediagroup.com/blog/2010/12/game-creation-with-unity3d/
i am also facing the same problem as fatema..
Mr. burton, please explain..
Thanku..
I have unity 3d iicense , i was asking about Corona .whats the difference btw its trial and full version?
For Corona, the difference between trial and full is the ability to publish to the iTunes or Android stores. You can deploy to local devices and fully develop the project, just can’t do the final build.
I am unable to get the starfighter model to import. I don’t have 3d studio on my machine, is that required to bring .max files into the Unity project?
What can I do?
You are correct, you do have to have 3DS Max to import the model. A trial version is available http://students.autodesk.com/
Hi, thanks for a great tutorial, sadly.. the scripts give lots of errors (just as Jay says:February 23, 2011 at 9:08 pm ).. Seems that the java scripts are intended for iphone (as you stated) so dont understand why they are iphone scripts and not android related scripts!!! corrections needed but not sure how to make the alterations! any advice for the player script for android (archos 101) please?, thank you
Hai Dr.Borton, first thx for Your great tutorial, and i have finished and try to build the spaceshooter.apk, and i try to put and installed to my android phone(x10 mini pro).
When i touch the install button.. the ‘loading process’ its take too so long, and brick my phone and then reboot the phone(before reboot, the screen is going black and white with abstract scratch).. what is the problem with that ? please help me.. sorry for my bad english..
Hey Dr Burton. A really nice tutorial, but I’m working on a mac and a .max file as model won’t work as far as I know. Do you have that model as a .fbx file or maybe just something else I could use to see what it would look like.
Thanks heaps
I just uploaded it. The FBX is now included with the download of assets.
Hi I started with your tutorial (http://www.burtonsmediagroup.com/blog/2010/12/creating-android-games-with-unity/) but there is a litle problem when I add the control script what is made for iphone or ipad it says iPhoneSettings.screenOrientation is bad so use ScreenOrientation blabla . so there was some of iOS inputs what I replaced with android inputs but the script is not working the model for I assisted it is not moving (http://nightslax.org/script.unitypackage) And there is other thing what i want to ask. When there is skybox for windows standalone the skybox is from 6 pictures but for the mobile is just one 2D picture to use. Is there any way to use the 6 picture skybox for mobile devices. Sorry for my bad english, please help.
btw nice tutorial
Sir, the assets zip file does not contain any scripts. I need to learn how to utilize the accelerometer. Thanks
Hi
Tnx for amazing Tutorial
I have a problem
when I want to run and test my game in AVD or my phone the apk file doesn’t made.I’m going to file>Build Settings and after set the player settings going to click on Build & Run .after that unity start Building.after a wile that ask me where the Android SDK is and I Select that Folder target then Nothing,Unity without no Errors Stoped the Prossesing and the apk file didn’t Made
Plz help!
And sry for my English
I also have this same problem. I followed all the steps [that I'm aware of] and I when I go to build and run everything is ok in loading all up to the end of the load where it tells me that the APK file could not be installed to check the console. I’m not sure what the console is either cause it doesn’t explain what it is, I’m guessing it’s the build settings area. Also, when I check the error code at the bottom, it says error is in the file 1 section. How do I check that I don’t know.
Hey great tutorial but if I wanted to do something XPERIA PLAY optimized what do I do?
Thanks for a great Tutorial there… This is what i looking for… really.. thanks
Hi
This is really a very useful tutorial for beginners, keep up your great work.
Thnak u for a great share.
Quality tutorial right here. You are a clear and calm speaker and really explained why we were changing those values, instead of just changing and not knowing what it really did.
Thank you, and don’t hesitate again to share your knowledge.
hi sir well ur tutorials were very helpful am strugling to get the button work in android but am not ble to solve the problem can u help me out please sir. thanks in advance
Thank you for the tutorial! However, I am having a problem with movement in the game… It seems that once i went through the tutorial, none of the asteroids are moving… Any help would be greatly appreciated!
hi, unity for Android and iOS are free until April 8th
Hi, i was wondering how i can connect my game made in unity3d with activities that i made in eclipse with java code? Or is there any way to create activities like “main menu”, “options” etc in unity3d? I will really apriciate any help, specially links with some tutorials.
Great job done btw.
I’m not sure where you are getting your information, but great topic. I needs to spend some time learning more or understanding more. Thanks for magnificent information I was looking for this info for my mission.
Hello Doc. Thanks for the great tutorial. How about the ‘Marmalade’ SDK? did you ever try that? I’m just trying to find out the best to learn.
Hi, and thanks for all the effort. I thought I had done everything according to your directions, but…when checking the adb devices in the command prompt, nothing is listed. When checking the device manager no phone is listed…so I can’t update the drivers…the android sdk is installed as is the java and eclipse. When running the “helloWorld” tutorial all appears fine but the text does not show up in the emulater. What am I missing….?
thanks again
Hullo, doc.
I read your comment of not having permission to release your game to any market. But I was wondering; Could you give an example of this?
I mean, if I make a game in a space, BASED off your tutorial, with custom materials and meshes and all. Would that still apply?
And how about the coding? Am I allowed to use them or tweak them and then use them for a game I publish?
Thanks in advance.
Creating something based off of one of my tutorials is fine. I just don’t want to see someone publishing what I created as their own work. Everything in the tutorial is available for your use.. just make it better, add your own code, graphics, effects, etc and make it YOUR game!
Dr.B , nice work on the tutorial, helps out alot.
Any chance of a tutorial for 2dPlatormers (Like doodlejump or HyperSpace). Also, would it be possible to do this without Rigidbody?
Daz, For 2D I prefer to use Corona SDK. It is lighter weight than Unity, easier to develop in, and looks great on mobile devices. You can see both games in the book I recently wrote “Mobile App Development with Corona: Getting Started” which is available on my website, Amazon, Kobo, and soon, the iBookstore.
Hi, my name is Shirley and I’m new in Unity. I want to ask.
I’ve already made a simple project using Unity for Android, but now I want to know how to adjust the screen because Android have many screen.
Thank you.
Hi Doc,
I’ve just stumbled upon this tutorial. Before i get myself engrossed in the videos i was hoping you can please answer a few questions for me.
Would you recommend building android apps before jumping into game development?
What skill level do you recommend someone must have before pursuing game development 2D/3D?
I understand that your opinion will be subjective but i’m keen to hear it nevetheless.
My background: Intermediate knowledge of java. I have created a few basic java gui apps and i do use eclipse.
Thank you,
fcs
@FCS,
Yes, experience creating non-game apps before tackling a game app is recommended. It gives you a change to learn the fundamentals of the development environment before tackling a more complex project like a game. Once you feel you are ready to do a game, I highly recommend doing a few 2D games before doing a 3D game. For game development I recommend Corona SDK by AnscaMobile.com for 2D and Unity3D.com for 3D games.
First of all, this tutorial is amazing.
Now, i finished the tutorial but mi ship is not moving, there’s a problem with the Player Control script, it says that a tag is missing, I believe they changed the scripts in the star trooper tutorial. Do you have any idea about how to fix the error?
I seem to be having the same problem.
This is the error that is occurring:
UnityException: Tag: SpaceCraft is not defined!
UnityEngine.GameObject.FindWithTag (System.String tag) (at C:/BuildAgent/work/b0bcff80449a48aa/Runtime/ExportGenerated/Editor/UnityEngineGameObject.cs:231)
PlayerControls.FixedUpdate () (at Assets/Scripts/PlayerControls.js:34)
Hi DrBurton, I followed all the steps [that I'm aware of] and I when I go to build and run everything is ok in loading all up to the end of the load where it tells me that the APK file could not be installed to check the console. I’m not sure what the console is either cause it doesn’t explain what it is, I’m guessing it’s the build settings area. Also, when I check the error code at the bottom, it says error is in the file 1 section. How do I check that I don’t know.
I’m afraid it will be a few weeks before I can get back to you on your questions.. it’s finals time here….
Ok Doc Thanks atleast for giving me heads up on it though. When you do come around and are able to answer us again, I just wanted to update you about my dilemma that I had, it’s all taken care of however I have been unsuccessful in being able to publish to my android device only the launch icon displays on my phone and the splashcreen but non of my work ever loads. I have followed everything to the “T” SDK, JDK, etc … all is installed properly I even have created the new keystore file [which gave me problems at first btw] but I was able to conquer the problem and whala ZIP,ZILCH, ZERO NADA lol . Well, hope you’ll be able to help me soon so I can restore some very needed encouragement on creating a game application. I will put my work on hold till you’re able to help me, this has exhausted me quite a bit.
Great tutorials by the way. I wish I can make you proud some day and create a spectacular game haha.
the tutorial on space shooter was very useful for me! thanks!
Thanx
this tutorial help me to learn
this only video on youtube can teach me
I get all kinds of errors when using the iphone js that is provided by Unity’s startroopers game. After importing them an attatching them to the the prefabs I ran the game and picked up plenty of errors. Isn’t this code only for iphones instead of android platform? How did you get it to function correctly?