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

Real-world adventure games


Real-world adventure games are a genre of games that has surged in popularity recently with the release of Pokemon GO. Chances are, at the time of reading this book, you may have certainly heard of, and likely have played, the popular game. Although many think this genre is an overnight sensation, it has in fact been around for several years. Niantic, the developer of Pokemon GO, released Ingress, its first real-world game, in November 2012. The title was, and is, popular, but has only attracted a niche following of gamers, which was likely more the result of the game's complex theme rather than being specific to the genre.

Now, many can suggest that the primary catalyst that launched Pokemon GO into a gaming sensation is the Pokemon franchise combined with a new augmented reality gaming platform. Certainly, without its integral real-world interaction, Pokemon GO would have been just another popular mobile game.

So, what are the elements that make a real-world adventure or location-based augmented reality game unique?

  • Location-based: Players have the ability to interact with virtual objects or places around them using a map. As the player physically moves in the real world, their device's GPS will update the player's location in the game, thus allowing the player to move to virtual locations and search for or interact with virtual objects or things. We will discover how to integrate the device's GPS and display a map in Chapter 2,Mapping the Player's Location.
  • Augmented Reality (AR): A player interacts with the real world through their device's camera. This allows them to view and interact with the virtual place or thing against the backdrop of the real world around them. Using the device's camera as a game background in order to enhance the user experience will be introduced in Chapter 5, Catching the Prey in AR.
  • Adventure game: Players typically assume the role of an avatar driven by a mission of exploration and puzzle solving in order to ultimately reach some story-driven goal. Of course, other notable games in the real-world genre may loosely fit that definition. For the purposes of this book, we will adhere to that loose definition of adventure game. The Introducing Foody GO section in this chapter will cover the game design and concept of the real-world adventure we will be building through the rest of the book.

Of course, there are many other elements that will be needed to create a successful game, but essentially, location-based and augmented reality are the elements that identify the real-world adventure genre. Astute readers may notice that massively multiplayer network gameplay or MMO was omitted. Although MMO gameplay may be essential to certain game designs, it is not a requirement of this genre.

Location-based

Tracking a player's location in the real world and then overlaying that into the game's virtual world creates a unique level of immersion for players. In fact, in many real-world adventure games, warning messages are presented to players before they start playing. There are many stories of players becoming so immersed that they have hurt themselves due to an avoidable accident while playing a real-world game.

Mapping the real world on top of the game's virtual world provides new challenges to traditional mobile gaming. Developing a map interface and populating it with virtual items require some advanced GIS skills. Many developers will be new or relatively inexperienced in the concepts of GPS and GIS or rendering a map in Unity. Since mapping is a core concept to the real-world genre, it will be the basis for much of the sample game we will be building. We will spend several chapters related to the topic of maps. The following is a list of chapters that will touch on mapping and location:

  • Chapter 2, Mapping the Player's Location, starts with a basic discussion of GPS and GIS and then show you how to load a map texture into a 3D Unity scene
  • Chapter 3, Making the Avatar, introduces the player character avatar and shows how the mobile's devices and the player's movement will control the avatar
  • Chapter 4, Spawning the Catch, is where we start to introduce virtual items onto the map and allow the player to find those items
  • Chapter 7, Creating the AR World, focuses on populating the virtual world around the player based on real-world locations
  • Chapter 8, Interacting with an AR World, allows the player to interact with those virtual locations

Augmented Reality

AR has been around since 1990. The term typically covers a broad range of technologies from virtual surgical devices, Microsoft HoloLens, and mobile apps such as Snapchat. AR technologies have been slow to become mainstream in gaming until just very recently. With the advance of new technologies and the real-world adventure genre being major contributors to increasing popularity of AR in gaming.

As mentioned, AR covers a broad range of technologies or devices that provide an overlaid virtual environment to the user. However, on a mobile device, the AR experience is often a result of rendering a virtual environment over a backdrop of the device's camera. In some cases, the AR game or application will have sophisticated image processing algorithms that identity features. Those identified features may then be annotated virtually with other graphics or game options. Pokemon GO, for instance, limits the use of AR to just the camera background, whereas Snapchat provides a dynamic AR experience to the user through the use of image processing. Yet, both the game and application benefit by providing the user with a more enjoyable experience through AR.

For the purpose of the real-world adventure genre and this book, we will take a basic approach to provide the user with a basic AR experience. That means, we will look at integrating the mobile device's camera as a game backdrop. The gaming experience will be familiar to other popular games in the genre. Even with this basic approach to AR, we will still cover a number of other details and tips in the course of a few chapters. The following is a short description of the AR elements that we will work on in the subsequent chapters:

  • Chapter 5, Catching the Prey in AR, will introduce using the mobile device's camera as our game's background
  • Chapter 9, Finishing the Game, will discuss some ideas for ways to enhance the AR gameplay
  • Chapter 10, Troubleshooting, will help you just in case things don't work as expected; this chapter will identify potential issues and provide tips to resolve them

Adventure games

Adventure games are typically characterized by a quest-driven story where players must explore and solve puzzles in order to complete the game, whereas the current real-world adventure games are more about exploration than puzzle solving and completing a quest. If anything, the current batch of real-world games are more like a Role-Playing Game (RPG) than a classic adventure game. In the future, we may certainly see more true classic adventure games or possibly other real-world mixes, such as real-time strategy, shooters, simulation, educational, sports, and puzzle.

In order to demonstrate how all these new concepts come together, we will be building a sample game throughout the book. This game will loosely follow an adventure style not unlike other popular titles in the real-world genre. In this game, we will be adding many common game elements, such as an avatar, character inventory, particle effects, and more in the course of several chapters; the following is a short introduction to those chapters:

  • Chapter 3, Making the Avatar, helps you to add a 3D rigged and animated character to our map
  • Chapter 4, Spawning the Catch, covers many concepts on GIS and mapping and features a short section on object animation
  • Chapter 5, Catching the Prey in AR, introduces AR and many other gaming concepts, such as texturing, rigid body physics, player input, AI, GUI menus, and particle effects
  • Chapter 6, Storing the Catch, introduces you to developing a persistent character inventory on a mobile device and more GUI development
  • Chapter 8, Interacting with an AR World, helps you add additional GUI elements and more particle effects and introduces visual effect shaders
  • Chapter 9, Finishing the Game, discusses the possibilities of enhancing the sample game or other ideas for a real-world game

Introducing Foody GO

Certainly, the best way to learn any new or advanced concepts is by example. Foody GO will be our example real-world adventure game that we will be building throughout the book. The game will follow a food theme where the player will search for and catch experimental cooking monsters. Once caught, the player must take their monsters to local restaurants in order to sell them for items, power and prestige.

Of course, our sample game will focus on the location-based augmented reality elements, but we will introduce several other technical features, as follows:

  • Player mapping
  • Augmented reality with the camera
  • Rigged and animated 3D avatar
  • Animated objects
  • Simple AI
  • Particle effects
  • GUI menus and controls
  • Persistent database storage
  • Visual shader effects

We won't get into extensive detail on any of the preceding features, as most of these items could cover a book by itself. However, it will be helpful to understand how each of these elements comes together to make a real-world adventure game.

Source code

All of the books source code can be downloaded from SITE. The source code will be broken down chapter by chapter and provided as a progressive project. For each chapter, the starting and ending project's states will be provided. This will allow the more advanced reader to jump ahead in the book. Novice readers are encouraged that you follow all the examples in the book, as later chapters will be more advanced in content.