Book Image

Augmented Reality Game Development

By : Micheal Lanham
Book Image

Augmented Reality Game Development

By: Micheal Lanham

Overview of this book

The heyday of location-based augmented reality games is upon us. They have been around for a few years, but the release of Pokémon Go was a gamechanger that catalyzed the market and led to a massive surge in demand. Now is the time for novice and experienced developers alike to turn their good ideas into augmented reality (AR) mobile games and meet this demand! If you are keen to develop virtual reality games with the latest Unity 5 toolkit, then this is the book for you. The genre of location-based AR games introduces a new platform and technical challenges, but this book will help simplify those challenges and show how to maximize your game audience. This book will take you on a journey through building a location-based AR game that addresses the core technical concepts: GIS fundamentals, mobile device GPS, mapping, map textures in Unity, mobile device camera, camera textures in Unity, accessing location-based services, and other useful Unity tips. The technical material also discusses what is necessary for further development to create a multiplayer version of the game. At the end, you will be presented with troubleshooting techniques in case you get into trouble and need a little help.
Table of Contents (17 chapters)
Augmented Reality Game Development
Credits
About the Author
About the Reviewer
www.PacktPub.com
Customer Feedback
Preface

Getting into mobile development with Unity


Now, with all the background set and our course laid out, let's get started by introducing mobile development with Unity. More advanced readers who have developed Unity games on Android or iOS may want to skip ahead to Chapter 2, Mapping the Player's Location.

This installation guide is intended to be cross-platform compatible and should work on Windows, Linux, or Mac. For the sake of brevity, only screenshots for the Windows platform will be shown.

Downloading and installing Unity

Even if you have installed Unity before, but have not done mobile development, make sure that you follow this section closely. There are a couple of important steps you would not want to miss.

Perform the following steps to install Unity:

  1. Open any browser and go to https://unity3d.com/.
  2. Browse through the site and download the Unity installer for the latest stable release. If you have never downloaded Unity before, you will need to create a new account.
  3. Run the Unity installer, click on Next to accept the license agreement and click on Next again.
  4. On the architecture dialog, shown in the following screenshot, make sure that you select 64 bit:

  5. On the select components dialog, make sure that you choose your preferred mobile platform, Android or iOS. Many users will just select all features and install. However, it is better to be selective and install only what you need. Installing all Unity features will require about 14 GB of space, and this can quickly add up if you have installed more than one version.

    In the following example screenshot, we have selected both Android and iOS. Ensure that you only select the platform you need:

    Choose only the components you need

  6. Select the default installation path for Unity and then click on Next to install.

Even with the limited number of components, the installation will still take several minutes, so grab a coffee and wait until it completes.

Setting up for Android development

If you are using an Android device to test the game, use this section to get ready. Developers who already have experience with Android can briefly review this section or jump ahead to the Getting Started with Unity section in this chapter.

Tip

Always install the same architecture version, 64 or 32 bit.

Installing the Android SDK

Follow the subsequent steps to install the Android SDK on your development computer. Even if you already have the SDK installed, please review these steps to ensure that you have the right path and components set:

  1. If you have not already done so, download and install the Java Development Kit (JDK) from http://www.oracle.com/technetwork/java/javase/downloads/index.html.

    Note

    Always note where you install a development kit like the JDK or SDK.

  2. Download the latest version of Android Studio from https://developer.android.com/studio/index.html.
  3. After Android Studio has finished downloading, follow the instructions on https://developer.android.com/studio/index.html to start installation.
  4. As you install Android Studio, make sure that you also install the Android SDK, as follows:

    Install the Android SDK component

  5. For the installation location, change the path to something that is easy for you to remember and locate. In the example screenshot, Android/AndroidStudio and Android/AndroidSDK are used:

    Select an installation location that will be easy to find later on

  6. After the installation completes, open Android Studio. Open the Android SDK Manager by selecting menu item Tools | Android | Android SDK. In the following example screenshot, only Android 5, API Level 21 is selected because it matches the device:

    Set the Android SDK location and select API level that matches your device

  7. On the Android SDK panel, set the location path to the same as you used in step 5. Then, select to install Android API level that matches your Android device and click on Apply. Locate the Android version of your phone from Settings | About phone | Android version. This API installation may take several minutes, so this will be a good time for another coffee or the beverage of choice.
  8. After the API installation completes, close Android Studio.

Connecting to your Android device

For best results when following the examples in this book, you will need to connect a physical device to your computer for testing. It is possible to emulate a GPS and camera in an Android emulator, but that is beyond the scope of this book. Follow these steps to get your device connected:

  1. Install the driver for your Android device by following this guide: https://developer.android.com/studio/run/oem-usb.html#InstallingDriver.
  2. Enable USB debugging on your Android device:

    • On Android 4.2 and higher: The Developer options screen is hidden by default. To make it visible, go to Settings | About phone and tap on Build number seven times. After the seventh tap, you will see a message informing you that the developer options are enabled. Return to the previous screen and select Developer options at the bottom to turn on USB debugging.
    • On older versions of Android, go to Settings | Applications | Development to turn on USB debugging.
  3. Connect your device to the computer. On the device you will be prompted to allow USB debugging. Choose Ok and wait for a few seconds to make sure that the driver connects.
  4. Open a command or console window on your computer and navigate to the Android/AndroidSDK folder where we installed the Android SDK to above.
  5. Run the following command-line commands:

    cd platform-tools
    
    adb devices
    
  6. Your device should show up in the list. If for some reason you do not see your device in the list, consult Chapter 10, Troubleshooting. The following console window shows the commands run and sample output:

That completes the bulk of setting up an Android device. We still have a couple more settings to make in Unity, but we will cover that in the next section on project setup.

Setting up for iOS development

In order to keep the content of this book focused and the development platform independent, we will not provide a step-by-step guide here. However, there is an excellent guide for iOS setup on the Unity site at https://unity3d.com/learn/tutorials/topics/mobile-touch/building-your-unity-game-ios-device-testing.

After you complete your iOS setup, return to the book, and we will begin building the example game project.