O'Reilly logo
live online training icon Live Online training

Ingenious Game AI Development in Unity

Implement AI for Games using Steering Behavior, Graphs, Pathfinding, Genetic and Machine Learning Algorithms

Jorge Palacios

In this course you will learn AI techniques and approaches to building games that exhibit human qualities, such as cleverness and decision-making, based on the environment and available agents.

This course aims to give hands-on exposure to develop agents and environments using an AI approach in Unity. We will start by understanding movement, using vectors and linear algebra, kinematic and dynamic movement. By understanding Steering Behaviors, we will implement our first agent. Subsequently, we will optimize the agent with Advanced Steering Behaviors that will help in implementing obstacle avoidance.

Moving further, we will jump on to Graphs and Pathfinding algorithms for our Game AI. You will then implement pathfinding and movement together. You will also learn about Finite State Machines and implement it using Unity's Animator FSM.

Later, we will explore NavMesh by creating basic navigations, complex navigations, creating different NavMesh Agents and implementing NavMesh baking. As the session proceeds from here, you will understand the genetic algorithm and its use in game AI to implement flow and dynamic difficulty adjustment.

Proceeding further, we will explore Unity’s ML Agents Toolkit. You will learn machine learning algorithms like Reinforcement and Q learning, and Imitation learning. You will then implement these algorithms for your game AI by training the agents using these algorithms with Unity's ML Toolkit. After the session, you will be confident in applying several techniques to develop more realistic and ingenious games with Unity.

What you'll learn-and how you can apply it

  • Kinematic and Dynamic movement
  • Steering Behavior and Graphs
  • Pathfinding algorithms and NavMesh API
  • Finite State Machines
  • Decision making techniques
  • Machine Learning techniques with ML Agents Toolkit
  • Procedural Content Generation algorithm

This training course is for you because...

  • You want to learn several techniques to apply right away in your games and create ingenious games with Unity.
  • You want to understand what features Unity has in store for AI development, from different points of view.


  • Basic knowledge of Python.
  • Basic Knowledge of Vectors and Linear Algebra will be helpful.
  • Working knowledge of C# scripting in Unity.

Materials, downloads, or Supplemental Content needed in advance


About your instructor

  • Jorge Palacios is a software and game developer with a BS in computer science and eight years of professional experience. He's been developing games for the last five years in different roles, from tool developer to lead programmer. Mainly focused on artificial intelligence and gameplay programming, he is currently working with Unity and HTML5. He's also a game-programming instructor, speaker, and game-jam organizer.


The timeframes are only estimates and may vary according to how the class is progressing


Section 1: Movement: Stepping stone for great AI (15 minutes)

  • Vectors and linear algebra
  • Kinematic movement
  • Dynamic movement
  • Steering behaviors
  • Review of Unity’s Execution Order of events

Lab 1: Implementing your first agent (30 minutes)

  • Implement player movement
  • Implement an agent’s movement framework
  • Implement different kinematic behaviors

Q&A – 10 minutes Break – 5 minutes

Section 2: Optimizing movement with physics and blending (10 minutes)

  • Acceleration and velocity
  • Linear and angular speed
  • Car movement math
  • Dynamic movement
  • Advanced steering behaviors

Lab 2: Implementing advanced agents (30 minutes)

  • Implement car movement
  • Implement dynamic steering behaviors
  • Implement behavior blending and obstacle avoidance

Q&A – 10 minutes Break – 10 minutes

Section 3: Graphs and Pathfinding Algorithms (20 Minutes)

  • Graph basics and implementation
  • Pathfinding algorithms (stacks and queues)
  • Depth-First Search
  • Breadth-First Search
  • Dijkstra
  • A*
  • A*mbush

Lab 3: In this lab we will cover the following (30 minutes)

  • Implement a graph
  • Create a graph visualization
  • Implement Depth-First Search
  • Implement Breadth-First Search
  • Implement Dijkstra
  • Implement A*
  • Implement A*mbush

Q&A – 10 minutes Break – 5 minutes

Section 4: Putting it all together (15 Minutes)

  • Pathfinding and movement
  • Finite-State Machines
  • Unity Animator’s FSM

Lab 4: In this lab we will cover the following (25 minutes)

  • Implement a path-following behavior
  • Implement a basic FSM
  • Implement behaviors using Unity’s FSM

Q&A and Wrap Up – 15 minutes


Section 5: The NavMesh and its API (15 minutes)

  • NavMesh basics
  • NavMesh API

Lab 5: Exploring the NavMesh API (35 minutes)

  • Creating navigation on a basic level
  • Creating navigation on a complex level
  • Creating different NavMesh agents
  • Implementing real-time NavMesh baking

Q&A – 10 minutes Break – 5 minutes

Section 6: Genetic Algorithm for Evolving Enemy Waves (20 minutes)

  • Understanding Genetic Algorithm and its use in Game AI.
  • Flow and Dynamic Difficulty adjustment

Lab 6: Implementing evolving enemy waves via Genetic Algorithm (25 minutes)

  • Enemy prefab
  • Enemy factory
  • Implementing Genetic algorithm

Q&A – 10 minutes Break – 10 minutes

Section 7: Exploring Unity ML Agents toolkit (15 Minutes)

  • Machine Learning basics
  • Unity ML Agents workflow

Q&A – 10 minutes

Section 8: Machine Learning Algorithms for Game AI using ML Agents (30 minutes)

  • Reinforcement and Q learning
  • Imitation learning

Lab 8: In this lab we will cover the following (45 minutes)

  • Training an agent with Reinforcement and Q learning using ML Agents.
  • Training an agent with Imitation learning using ML Agents.

Q&A and wrap up – 10 Minutes