Unity 4.x Game AI Programming

Unity 4.x Game AI Programming
eBook: $26.99
Formats: PDF, PacktLib, ePub and Mobi formats
save 15%!
Print + free eBook + free PacktLib access to the book: $71.98    Print cover: $44.99
save 44%!
Free Shipping!
UK, US, Europe and selected countries in Asia.
Also available on:
Table of Contents
Sample Chapters
  • A practical guide with step-by-step instructions and example projects to learn Unity3D scripting
  • Learn pathfinding using A* algorithms as well as Unity3D pro features and navigation graphs
  • Implement finite state machines (FSMs), path following, and steering algorithms

Book Details

Language : English
Paperback : 232 pages [ 235mm x 191mm ]
Release Date : July 2013
ISBN : 1849693404
ISBN 13 : 9781849693400
Author(s) : Aung Sithu Kyaw, Clifford Peters, Thet Naing Swe
Topics and Technologies : All Books, Game Development, Unity

Table of Contents

Chapter 1: Introduction to AI
Chapter 2: Finite State Machines
Chapter 3: Random and Probability
Chapter 4: Implementing Sensors
Chapter 5: Flocking
Chapter 6: Path Following and Steering Behaviors
Chapter 7: A* Pathfinding
Chapter 8: Navigation Mesh
Chapter 9: Behavior Trees
Chapter 10: Putting It All Together
  • Chapter 1: Introduction to AI
    • Artificial Intelligence (AI)
    • AI in games
    • AI techniques
      • Finite State Machines (FSM)
      • Random and probability in AI
      • The sensor system
        • Polling
        • The messaging system
      • Flocking, swarming, and herding
      • Path following and steering
      • A* pathfinding
      • A navigation mesh
      • The behavior trees
      • Locomotion
      • Dijkstra's algorithm
    • Summary
    • Chapter 2: Finite State Machines
      • The player's tank
        • The PlayerTankController class
        • Initialization
          • Shooting bullet
          • Controlling the tank
      • The bullet class
      • Setting up waypoints
      • The abstract FSM class
      • The enemy tank AI
        • The patrol state
        • The chase state
        • The attack state
        • The dead state
          • Taking damage
      • Using an FSM framework
        • The AdvanceFSM class
        • The FSMState class
        • The state classes
          • The PatrolState class
        • The NPCTankController class
      • Summary
      • Chapter 3: Random and Probability
        • Random
          • Random class
            • Simple random dice game
        • Definition of probability
          • Independent and related events
          • Conditional probability
            • A loaded dice
        • Character personalities
        • FSM with probability
        • Dynamic AI
        • Demo slot machine
          • Random slot machine
          • Weighted probability
            • Near miss
        • Summary
        • Chapter 4: Implementing Sensors
          • Basic sensory systems
          • Scene setup
          • Player tank and aspect
            • Player tank
            • Aspect
          • AI character
            • Sense
            • Perspective
            • Touch
          • Testing
          • Summary
          • Chapter 5: Flocking
            • Flocking from Unity's Island Demo
              • Individual Behavior
              • Controller
            • Alternative implementation
              • FlockController
            • Summary
              • Chapter 7: A* Pathfinding
                • A* algorithm revisit
                • Implementation
                  • Node
                  • PriorityQueue
                  • GridManager
                  • AStar
                  • TestCode class
                • Scene setup
                • Testing
                • Summary
                • Chapter 8: Navigation Mesh
                  • Introduction
                  • Setting up the map
                    • Navigation Static
                    • Baking the navigation mesh
                    • Nav Mesh Agent
                      • Updating agents' destinations
                  • Scene with slope
                  • NavMeshLayers
                  • Off Mesh Links
                    • Generated Off Mesh Links
                    • Manual Off Mesh Links
                  • Summary
                  • Chapter 9: Behavior Trees
                    • Behave plugin
                    • Workflow
                    • Action
                    • Interfacing with the script
                    • Decorator
                    • Behave debugger
                    • Sequence
                    • Exploring Behave results
                    • Selector
                    • Priority selector
                    • Parallel
                    • Reference
                    • The Robots versus Aliens project
                    • Summary
                    • Chapter 10: Putting It All Together
                      • Scene setup
                        • Tags and layers
                      • Vehicles
                        • Player car controller
                        • AI Car Controller
                        • Finite State Machines (FSMs)
                          • Patrol state
                          • Chase state
                          • Attack state
                      • Weapons
                        • Gun
                        • Bullet
                        • Launcher
                        • Missile
                      • Summary

                      Aung Sithu Kyaw

                      Aung Sithu Kyaw is originally from Myanmar, (Burma) and has over seven years of experience in the software industry. His main interests include game-play programming, startups, entrepreneurship, writing, and sharing knowledge. He holds a Master of Science degree from Nanyang Technological University (NTU), Singapore, majoring in Digital Media Technology. Over the past few years, he has worked as a Research Programmer at INSEAD, Sr. Game Programmer at Playware Studios Asia, Singapore, and lastly as a Research Associate at NTU. In 2011, Aung co-founded Rival Edge Pte Ltd., a Singapore-based interactive digital media company that provides a technical consultancy service to creative agencies and also produces social mobile games. Visit http://rivaledge.sg for more information. Aung is the co-author of Irrlicht 1.7 Realtime 3D Engine Beginner's Guide, Packt Publishing, and is also a visiting lecturer at NTU conducting workshops on game design and development using Unity3D.He can be followed on Twitter @aungsithu and by using his LinkedIn profile linkedin.com/in/aungsithu.

                      Clifford Peters

                      Clifford Peters is a programmer and a computer scientist. He has reviewed the following Packt Publishing books: Unity Game Development Essentials, Unity 3D Game Development by Example Beginner's Guide, Unity 3 Game Development Hotshot, Unity 3.x Game Development by Example Beginner's Guide, Unity iOS Game Development Beginner's Guide, and Unity iOS Essentials.

                      Thet Naing Swe

                      Thet Naing Swe is the co-founder and Chief Creative Director of Rival Edge Pte Ltd., based in Singapore. He graduated from the University of Central Lancashire where he majored in Game Design and Development and started his career as a game programmer at the UK-based Code Monkeys studios. He relocated to Singapore in 2010 and worked as a graphics programmer at Nanyang Technological University (NTU) on a cinematic research project together with Aung. Currently at Rival Edge, he's responsible for interactive digital media consulting projects mainly using Unity3D as well as making social mobile games for a casual audience. He can be reached via thetnswe@rivaledge.sg.

                      Code Downloads

                      Download the code and support files for this book.

                      Submit Errata

                      Please let us know if you have found any errors not listed on this list by completing our errata submission form. Our editors will check them and add them to this list. Thank you.


                      - 4 submitted: last submission 27 May 2014

                      Errata type: Others | Page number: 27

                      As mentioned on page number 27, there is no explanation for unity locomotion system in the later chapter, instead for a detailed explanation on unity locomotion system you can refer to the following link: https://www.assetstore.unity3d.com/#/search/locomotion%20system

                      Errata type: Code | Page number: 70

                      The line     nt remainingValuesProb = (100 - zeroProbability)/9;

                      should be  int remainingValuesProb = (100 - zeroProbability)/9;

                      Errata type: Code | Page number: 60

                      The line:
                          "diceResult = Random.Range(1,5);"

                      should be:

                          "diceResult = Random.Range(1,6);"

                      Errata type: Code | Page number: 67

                      The line:     if (GUI.Button(new Rect(200, 300, 150, 40), "Pull Liver")) 

                      Should be:  if (GUI.Button(new Rect(200, 300, 150, 40), "Pull Lever")) 

                      Sample chapters

                      You can view our sample chapters and prefaces of this title on PacktLib or download sample chapters in PDF format.

                      Frequently bought together

                      Unity 4.x Game AI Programming +    Node.js Blueprints =
                      50% Off
                      the second eBook
                      Price for both: £26.35

                      Buy both these recommended eBooks together and get 50% off the cheapest eBook.

                      What you will learn from this book

                      • Building finite state machines (FSMs)
                      • Implementing a sensory system
                      • Applying flocking behavior for a crowd
                      • Executing your own A* pathfinding algorithm in Unity3D
                      • Applying random and probability techniques in a betting game
                      • Using the Unity3D pro feature, navigation graphs, for path finding
                      • Learning about behavior trees and the Behave plugin
                      • Implementing a racing game AI through the final chapter project

                      In Detail

                      This book fills the gap between artificial intelligence (AI) books designed to learn underlying AI algorithms and general Unity3D books written to cover basic scene setup and scripting in Unity3D. Game AI Scripting in Unity3D covers implementing AI techniques such as flocking, pathfinding, path following, and behavior trees in Unity3D with example projects.

                      Game AI Scripting in Unity3D will show you how to apply AI techniques to your Unity3D projects using C# as the scripting language. Unlike other AI books and Unity3D books, this book tries to focus more on the application of AI techniques in the Unity3D engine, with sample projects that demonstrate finite state machines (FSMs), pathfinding, steering, navigation graphs, and behavior trees techniques.

                      This book shows how to implement various AI techniques in Unity3D by implementing the algorithm from scratch using C#, applying Unity3D built-in features, or using available scripts and plugins from the Unity Asset Store. For example, we’ll be implementing our own A* algorithm to do pathfinding but will also explore the Unity3D navigation graphs feature. Then we’ll use the Behave plugin to construct behavior trees for intelligent AI character behaviors.

                      Game AI Scripting in Unity3d  covers other AI techniques such as flocking behavior, building a sensory system for taking inputs from the environment and other AI agents, and so on. In the final chapter this book will show you how to build a racing game AI project using Unity3D and applying the techniques described in earlier chapters.


                      Step-by-step practical tutorial

                      Who this book is for

                      Are you are a programmer with basic knowledge of Unity3D who would like to add AI features to your game? Are you looking for a reference on implementing AI in Unity3D with simple to follow instructions, and lots of sample code and projects? Then this book is for you. You should have some background in C# language as this book will use C# for scripting. However if you know any other language you should be able to follow this book fairly easily.

                      Code Download and Errata
                      Packt Anytime, Anywhere
                      Register Books
                      Print Upgrades
                      eBook Downloads
                      Video Support
                      Contact Us
                      Awards Voting Nominations Previous Winners
                      Judges Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software
                      Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software