Book Image

Unity AI Programming Essentials

By : Curtis Bennett
Book Image

Unity AI Programming Essentials

By: Curtis Bennett

Overview of this book

Table of Contents (19 chapters)

Preface

Welcome to Unity AI Programming Essentials. This book will guide you through all the skills necessary to put realistic game AI into your Unity games. We won't be spending much time discussing AI theory or how to implement popular AI algorithms from scratch. Instead, we will take the more efficient approach of using third-party Unity AI plugins to set up AI for your games easily. We will cover all the essential game AI skills, such as pathfinding to have your characters navigate a game scene, behavior trees to let them "think", and sensors so that they can react to their environment. We'll also cover more specialized tasks such as setting up crowds and cars for driving and integrating animation. By the end of the book, you should know all the basic skills you need to create game AI with Unity.

What this book covers

Chapter 1, Pathfinding, covers how to set up basic pathfinding so that game characters can navigate a game scene realistically.

Chapter 2, Patrolling, extends our pathfinding to have characters patrol routes in a scene.

Chapter 3, Behavior Trees, explains behavior trees and how they are used to give AI characters the ability to make decisions.

Chapter 4, Crowd Chaos, focuses on creating a wander behavior that can be used to create ambient crowds.

Chapter 5, Crowd Control, demonstrates using specialized crowd plugins how to generate groups of AI characters.

Chapter 6, Sensors and Activities, shows how to set up sensors and have AI characters change their activity based on what they sense in the environment.

Chapter 7, Adaptation, shows how to have AI characters react and adapt to different events in the game.

Chapter 8, Attacking, discusses different techniques to have an enemy AI attack the player.

Chapter 9, Driving, shows how to set up driving AI that uses a car's physics to generate realistic driving behavior.

Chapter 10, Animation and AI, discusses how to integrate character animation with AI using both Unity's legacy and Mecanim animation systems.

Chapter 11, Advanced NavMesh Generation, discusses more advanced options for setting up navigation meshes to handle mesh creation for different geometries and multiple NavMeshs in a scene.

What you need for this book

This book uses Unity 4 with a standard license. Additionally, it uses RAIN, a Unity AI plugin that is available for free from http://rivaltheory.com/rain/. Additional plugins are used such as React AI and AI plugins for crowds and driving that can be purchased from the Asset Store, for which details are provided in the appropriate chapters.

Who this book is for

This book is aimed at developers who know the basics of game development with Unity and want to learn how to add AI to their games. You do not need any previous AI knowledge; this book will explain all the essential AI concepts and show you how to add and use them in your games.

Conventions

In this book, you will find a number of styles of text 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: "We find all the NavigationTargetRig objects and store them in the coverPoints array."

A block of code is set as follows:

public override void Start(AI ai)
{
     base.Start(ai);

     ai.WorkingMemory.SetItem("donePatrolling", true);
}

New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: "In the AI game object/component that was added, from the Mind tab, set Behavior Tree Asset to RandomWalk."

Note

Warnings or important notes appear in a box like this.

Tip

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 , 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 from your account at http://www.packtpub.com for all the Packt Publishing books you have purchased. 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.

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: https://www.packtpub.com/sites/default/files/downloads/3556OT_ColoredImages.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 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 , and we will do our best to address the problem.