
Unity 2017 Game AI Programming - Third Edition
- 250 pages
- English
- ePUB (mobile friendly)
- Available on iOS & Android
Unity 2017 Game AI Programming - Third Edition
About this book
Use Unity 2017 to create fun and unbelievable AI entities in your games with A*, Fuzzy logic and NavMeshAbout This Book• Explore the brand-new Unity 2017 features that makes implementing Artificial Intelligence in your game easier than ever• Use fuzzy logic concepts in your AI decision-making to make your characters more engaging• Build exciting and richer games by mastering advanced Artificial Intelligence concepts such as Neural NetworksWho This Book Is ForThis book is intended for Unity developers with a basic understanding of C# and the Unity editor. Whether you're looking to build your first game or are looking to expand your knowledge as a game programmer, you will find plenty of exciting information and examples of game AI in terms of concepts and implementation.What You Will Learn• Understand the basic terminology and concepts in game AI• Explore advanced AI Concepts such as Neural Networks• Implement a basic finite state machine using state machine behaviors in Unity 2017• Create sensory systems for your AI and couple it with a Finite State Machine• Wok with Unity 2017's built-in NavMesh features in your game• Build believable and highly-efficient artificial flocks and crowds• Create a basic behavior tree to drive a character's actionsIn DetailUnity 2017 provides game and app developers with a variety of tools to implement Artificial Intelligence. Leveraging these tools via Unity's API or built-in features allows limitless possibilities when it comes to creating your game's worlds and characters. This third edition with Unity will help you break down Artificial Intelligence into simple concepts to give you a fundamental understanding of the topic to build upon. Using a variety of examples, the book then takes those concepts and walks you through actual implementations designed to highlight key concepts, and features related to game AI in Unity 5. Further on you will learn to distinguish the state machine pattern and implement one of your own. This is followed by learning how to implement a basic sensory system for your AI agent and coupling it with a Finite State Machine (FSM).Next you'll learn how to use Unity's built-in NavMesh feature and implement your own A* pathfinding system. You will then learn how to implement simple flocks and crowd's dynamics, key AI concepts. Moving on, you will learn how to implement a behavior tree through a game-focused example. Lastly, you'll combine fuzzy logic concepts with state machines and apply all the concepts in the book to build a simple tank game.Style and approachA self-explanatory practical guide with a series of tips and tricks on creating AI games with ease.
Frequently asked questions
- Essential is ideal for learners and professionals who enjoy exploring a wide range of subjects. Access the Essential Library with 800,000+ trusted titles and best-sellers across business, personal growth, and the humanities. Includes unlimited reading time and Standard Read Aloud voice.
- Complete: Perfect for advanced learners and researchers needing full, unrestricted access. Unlock 1.4M+ books across hundreds of subjects, including academic and specialized titles. The Complete Plan also includes advanced features like Premium Read Aloud and Research Assistant.
Please note we cannot support devices running on iOS 13 and Android 7 or earlier. Learn more about using the app.
Information
Finding Your Way
- Path following and steering
- A custom A* Pathfinding implementation
- Unity's built-in NavMesh
Technical Requirements
https://github.com/PacktPublishing/Unity-2017-Game-AI-Programming-Third-Edition/tree/master/Chapter04
https://goo.gl/Eoxby1
Following a path

The path script
using UnityEngine;
public class Path: MonoBehaviour
{
[SerializeField]
private Vector3[] waypoints;
public bool isDebug = true;
public float radius = 2.0f;
public float PathLength {
get { return waypoints.Length; }
}
public Vector3 GetPoint(int index)
{
return waypoints[index];
}
private void OnDrawGizmos()
{
if (!isDebug) {
return;
}
for (int i = 0; i < waypoints.Length; i++)
{
if (i + 1 < waypoints.Length)
{
Debug.DrawLine(waypoints[i], waypoints[i + 1], Color.red);
}
}
}
}

Using the path follower
public class Pathing : MonoBehaviour
{
[SerializeField]
private Path path;
[SerializeField]
private float speed = 20.0f;
[SerializeField]
private float mass = 5.0f;
[SerializeField]
private bool isLooping = true;
private float currentSpeed;
private int currentPathIndex = 0;
private Vector3 targetPoint;
private Vector3 direction;
private Vector3 targetDirection;

Table of contents
- Title Page
- Copyright and Credits
- Packt Upsell
- Contributors
- Preface
- The Basics of AI in Games
- Finite State Machines and You
- Implementing Sensors
- Finding Your Way
- Flocks and Crowds
- Behavior Trees
- Using Fuzzy Logic to Make Your AI Seem Alive
- How It All Comes Together
- Other Books You May Enjoy