Book Image

Mastering Android Game Development with Unity

By : Siddharth Shekar
Book Image

Mastering Android Game Development with Unity

By: Siddharth Shekar

Overview of this book

Game engines such as Unity are the power-tools behind the games we know and love. Unity is one of the most widely-used and best loved packages for game development and is used by everyone, from hobbyists to large studios, to create games and interactive experiences for the Web, desktop, mobile, and console. With Unity's intuitive, easy-to-learn toolset and this book, it's never been easier to become a game developer. You will begin with the basic concepts of Android game development, a brief history of Android games, the building blocks of Android games in Unity 5, and the basic flow of games. You will configure an empty project for the Jetpack Joyride Clone Game, add an environment and characters, and control them. Next you will walk through topics such as particle systems, camera management, prefabs, animations, triggers, colliders, and basic GUI systems. You will then cover the basic setup for 3D action fighting games, importing models, textures and controlling them with a virtual on-screen joystick. Later you will set up Scene for 3D Configuration, create basic gameplays, and manage input controls. Next you will learn to create the interface for the main menu, gameplay, game over, achievements, and high score screens. Finally you will polish your game with stats, sounds, and Social Networking, followed by testing the game on Android devices and then publishing it on Google Play, Amazon, and OUYA Stores.
Table of Contents (15 chapters)
Title Page
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Customer Feedback
Preface

Preface

Unity has come a long way from its humble beginnings; however, since the last couple of years, it has almost become an industry-wide used tool that almost all independent game developers use to develop their games. It is very easy to use to develop prototypes, and when you have a successful idea, it is flexible enough to expand the small prototype to a full-fledged game.

Despite its professional capacity, Unity is so simple to use that even a complete novice person can develop a basic game within a matter of hours. And with a little more effort, a very polished game can be developed with excellent lighting and animation.

With the current version, Unity makes game development even more accessible to everyone.

In this book, we will cover a variety of topics both in 2D and 3D game development. We will see how to develop a game similar to JetPack Joyride in 2D, and a 3D fighting game with full 3D animation, lighting, and camera. We will also see how to add buttons, text, and screen transitions. Finally, once we have created the game, we will see how to monetize it by adding in-app purchases and ads.

What this book covers

Chapter 1, Introduction to Android Game Development with Unity3D, covers the basic concepts of Android game development, a brief history of Android games, the building blocks of Android games in Unity3D, and the basic flow of games.

Chapter 2, Finishing the Perky Penguin 2D Game, extends 2D game development by finishing the Jetpack Joyride clone game. The chapter introduces various topics, such as particle systems, camera management, prefabs, animations, triggers, colliders, and basic GUI systems.

Chapter 3, Player Character for Action Fighting Game, covers the basic setup for 3D action fighting game, importing models and textures, setting rigging for the characters, applying animations on models, and controlling the player character with a virtual on-screen joystick.

Chapter 4, Enemy Character with AI, covers the aspect of creating the enemy model of the game from importing models to applying animations to decision making with AI.

Chapter 5, Gameplay, UI, and Effects, shows how to finish the gameplay loop, add a UI, add text for scoring the game, and add particle effects to the game.

Chapter 6, GameScene and SceneFlow, covers the creation of MainMenu Scene, explains Options Scene, and demonstrates how to transition between the scenes in the game.

Chapter 7, Gamestats, Social, IAP and Ad integration, demonstrates how to save in-game progress, add social media integration such as Facebook and Twitter, ad integration, and In-App purchases to add monetization.

Chapter 8, Sound, Finishing Touches, and Publishing, lets us add finishing touches to the game and add sound. We will see how to run the game on the device and publish the game to the Android Play Store.

What you need for this book

You will need the latest version of Unity, which you can download from their website, and a computer that can run Unity. A basic understanding of C# is required as the code in this book is written in C#. Although the game can run on an Android emulator, to see the actual performance of the game, an Android device would be required.

Who this book is for

This book is geared toward novice or intermediate Unity3D developers who want to expand their knowledge of Unity3D and create high-end, complex Android games. You are expected to have a basic or intermediate understanding of Unity3D, working with its environment, basic concepts such as Game Objects and Prefabs, Unity Scripting using C# or JavaScript, and how to develop basic 2D/3D games using Unity3D.

The book is very useful for those Unity developers who have created basic/simple games for Android and want to learn the ins and outs and core components of high-end complex games that have features such as detailed animations, multiple levels, character abilities, enemy weaknesses, intelligent AI, achievements, leaderboards, and a lot more.

Conventions

In this book, you will find a number of text styles that distinguish between different kinds of information. Here are some examples of these styles and an explanation of their meaning.

Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "ThebIsDefending variable is the same as that we defined as a parameter in Animation Controller."

A block of code is set as follows:

    private Animator anim;
    // Use this for initialization

    void Start () {
        anim = GetComponent<Animator>();
    } // start

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

    if (pAnim.GetBool("tIsPunching")){
        if (anim.GetBool("bEnemyIsDefending") == false) {
            Debug.Log("enemy got hit");
            anim.SetTrigger("tEnemyGotHit");
            anim.SetBool("bEnemyIsDefending", true);
            health -= pScript.damage;
        }
    }

Any command-line input or output is written as follows:

C:\Program Files\Unity\Editor\Unity.exe

New terms and important words are shown in bold. Words that you see on the screen, for example, in menus or dialog boxes, appear in the text like this: "Unity lets developers manage these components of each game object through the Inspector panel."

Note

Warnings or important notes appear in a box like this.

Note

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of.

To send us general feedback, simply e-mail [email protected], and mention the book's title in the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide at www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files for this book from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

You can download the code files by following these steps:

  1. Log in or register to our website using your e-mail address and password.
  2. Hover the mouse pointer on the SUPPORT tab at the top.
  3. Click on Code Downloads & Errata.
  4. Enter the name of the book in the Search box.

 

  1. Select the book for which you're looking to download the code files.
  2. Choose from the drop-down menu where you purchased this book from.
  3. Click on Code Download.

Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:

  • WinRAR / 7-Zip for Windows
  • Zipeg / iZip / UnRarX for Mac
  • 7-Zip / PeaZip for Linux

The code bundle for the book is also hosted on GitHub at https://github.com/PacktPublishing/Mastering-Android-Game-Development-with-Unity. We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!

Downloading the color images of this book

We also provide you with a PDF file that has color images of the screenshots/diagrams used in this book. The color images will help you better understand the changes in the output. You can download this file from http://www.packtpub.com/sites/default/files/downloads/MasteringAndroidGameDevelopmentwithUnity_ColorImages.pdf.

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you could report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website or added to any list of existing errata under the Errata section of that title.

To view the previously submitted errata, go to https://www.packtpub.com/books/content/support and enter the name of the book in the search field. The required information will appear under the Errata section.

Piracy

Piracy of copyrighted material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at [email protected] with a link to the suspected pirated material.

We appreciate your help in protecting our authors and our ability to bring you valuable content.

Questions

If you have a problem with any aspect of this book, you can contact us at [email protected], and we will do our best to address the problem.