Creating Android games with Unity

Posted by Dr. Burton on December 17, 2010 in Android, Game Development, iPad, iPhone, Mobile, Unity3D |

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.

Creating games for the Android with Unity
Runtime
19:59
View count
71,142

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.

Creating games for the Android with Unity - Part 2
Runtime
18:25
View count
29,791

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

Tags: , , , , ,

81 Comments

  • Hoang Phuong says:

    I need this source Unity, you can share it???? Thank you very much

    • Dr. Burton says:

      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.

      • charlton says:

        if i publish to android market can i play it?

      • Dr. Burton says:

        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.

      • charlton says:

        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

      • Dr. Burton says:

        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.

  • kagura says:

    I need resource of this tutorial: psd sky, rock, texture, scene, …
    Can you share it? Thanks.

  • phongtt says:

    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 ?

    • Dr. Burton says:

      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.

  • Alex says:

    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

  • Alex says:

    Good Night!
    Where is the spaceship?
    thanks
    Sorry my poor english, is not my native language
    Thanks in advance

  • than says:

    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

  • Dan says:

    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

    • Dr. Burton says:

      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.

      • karthik says:

        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..

    • Marcos says:

      Update Unity.
      3.3 are fixed this problem.

  • Jay says:

    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?

    • Dr. Burton says:

      I have updated the zip file to include the ship and it’s textures.

      • Jay says:

        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.

  • Natious says:

    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

  • dahsto says:

    Thank you so much Doc’ for this tutorial. You explain so nice, everything becomes easy :)

    Please keep going the great work !

  • victorelli says:

    Hi Dr. Burton, great work.

    Please add scripts for download.

  • reg me says:

    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

  • fatema says:

    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

  • omar says:

    HEy starfighter 02 texture is missing i think,it doesnt make that package shape so i cant apply the textures..kindly look the file?

  • omar says:

    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

    • Dr. Burton says:

      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.

  • omar says:

    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

    • Dr. Burton says:

      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.

      • omar says:

        can u tell me whats the difference between full and trial version?
        i already have unity 3d.

      • Dr. Burton says:

        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.

  • fatema says:

    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.

  • khushboo says:

    i am also facing the same problem as fatema..
    Mr. burton, please explain..

    Thanku..

  • omar says:

    I have unity 3d iicense , i was asking about Corona .whats the difference btw its trial and full version?

  • John Wolf says:

    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?

  • neil says:

    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 :)

  • eve says:

    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..

  • Juls says:

    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

  • BoKKeR says:

    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 :)

  • John Smith says:

    Sir, the assets zip file does not contain any scripts. I need to learn how to utilize the accelerometer. Thanks

  • papmodern says:

    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 :)

    • Avraham says:

      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.

  • PJ says:

    Hey great tutorial but if I wanted to do something XPERIA PLAY optimized what do I do?

  • ianseer says:

    Thanks for a great Tutorial there… This is what i looking for… really.. thanks

  • Dilliraj says:

    Hi
    This is really a very useful tutorial for beginners, keep up your great work.
    Thnak u for a great share.

  • Lan says:

    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

  • Ryan says:

    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!

  • Anonymous says:

    hi, unity for Android and iOS are free until April 8th

  • haawa says:

    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.

  • Janson says:

    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.

  • Mark says:

    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

  • Nicky Wild says:

    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.

    • Dr. Burton says:

      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!

  • Daz Gozzett says:

    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?

    • Dr. Burton says:

      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.

  • Shirley says:

    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.

  • fcs says:

    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

    • Dr. Burton says:

      @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.

  • Antonio says:

    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?

    • ZacH says:

      I seem to be having the same problem.

      • Zach says:

        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)

  • Avraham says:

    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.

    • Dr. Burton says:

      I’m afraid it will be a few weeks before I can get back to you on your questions.. it’s finals time here….

      • Avraham says:

        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.

      • dmerene says:

        the tutorial on space shooter was very useful for me! thanks! :)

  • eri albar says:

    Thanx

    this tutorial help me to learn
    this only video on youtube can teach me

  • Avraham says:

    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?

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Spam Protection by WP-SpamFree

Copyright © 2010-2012 Burtons Media Group All rights reserved.
Desk Mess Mirrored version 1.9.1 theme from BuyNowShop.com.