The Beginner's Guide to Artificial Intelligence in Unity.
4.7 (996 ratings)
13,067 students enrolled

# The Beginner's Guide to Artificial Intelligence in Unity.

A practical guide to programming non-player characters for games.
Bestseller
4.7 (996 ratings)
13,067 students enrolled
Last updated 3/2019
English
English [Auto-generated]
Current price: \$15.00 Original price: \$149.99 Discount: 90% off
30-Day Money-Back Guarantee
This course includes
• 9 hours on-demand video
• 12 articles
• Access on mobile and TV
• Certificate of Completion
Training 5 or more people?

What you'll learn
• Design and program NPCs with C# in Unity

• ### Implement AI related Unity Asset plugins into existing projects

• Work with a variety of AI techniques for developing navigation and decision making abilities in NPCs
Course content
Expand all 60 lectures 09:08:08
+ Introduction
5 lectures 21:06

This lecture introduces the course by outlining all the content that will be covered with a section by section breakdown.

Preview 03:26
FAQ's
00:01

In this lecture we will get an overview of vectors and why they are an important concept to have an understanding of before you launch into programming the movement of an NPC.

Preview 07:04
Vector Mathematic Basics Cheat Sheet
05:15
10 questions
Unity uses the FBX file format by default to represent 3D models. Within Unity 2017 and greater the way the files are dealt with has changed slightly and may cause you to lose the textures from your models. Take note of the process in this lecture that will assist you in fixing this issue when you encounter it later in the course.
Important Note Regarding Unity Updates to FBX Model Importing
05:19
+ Moving
7 lectures 58:11

In this lecture we will take a quick look at the nature of vectors and then discuss through a practical application how they can be used to move a character forward at a constant speed.

Vectors and Moving in a Straight Line
11:50

Follow along in the lecture as we setup a goal location for the character to move towards. You will also be shown how to change the facing direction of a character such that it looks in the direction it is travelling.

Traveling to a Goal Location
12:21

In this lecture we will examine a different approach to moving the character. This time instead of setting a vector to travel along we will turn the character towards a goal and then push the character in a forward direction.

Pushing the Character Forward
12:40

Instead of snapping a character around to face a goal in a single update you may want more smooth turning behaviour to occur that makes the movement appear more natural. In this lecture we will examine the slerp method for achieving this.

Slerping
05:19

In this lecture we will take a quick look at the difference between animation translation and translating with code. Eitherway is acceptable and it will depend on what you are trying to achieve with the look of your character as to which one is more appropriate.

06:38

In this lecture we will look at the simplest form of AI navigation: waypoints. Using the code we've developed thus far by giving the NPC an array of goals we can change its behaviour from chasing to patrolling.

Waypoints
09:10
Challenge
00:13
+ Cars
4 lectures 49:40

If you import the Utilities from Unity's included assets you'll find code for setting up waypoints and navigating a circuit. In this lecture we will look at how to integrate these Unity asset's with our own code.

Unity's Waypoint System
12:38

In this lecture we will examine how to create a simple car NPC that can accelerate and brake while following a circuit tracker.

Car Racing with Waypoints
13:25

Continuing where we left the previous lecture we will add in another car and set about making the properties of the movement behaviour customisable.

Customising Car Behaviours
07:59

Inside Unity's Standard Assets you will find the setup for a Waypoint following AI car with many customisable properties. In this lecture we will explore this feature as well as discuss how to add your own custom model into the system.

Unity's Vehicle System
15:38
+ Waypoints
5 lectures 39:40

Graph Theory underpins so many AI techniques and it certainly deserves some focussed attention. In this lecture we will examine the structure of graphs and several path searching algorithms will be discussed.

Preview 08:31

In this lecture we will apply the A* algorithm to finding a path through a system of waypoints converted into a graph.

Pathfinding through Waypoints
19:31

In part 2 of this hands-on workshop to put together a waypoint graph traversal system using the A * algorithm we will add UI buttons to send location commands to the NPC.

Pathfinding through Waypoints Part 2
10:17
Challenge
00:13

This short article will explain how the code for dealing with 3D waypoints can be modified for 2D environments.

Waypoints in 2D
01:08
+ NavMeshes
9 lectures 01:23:20

In this lecture we will modify the pathfinding exercise created thus far and introduce the concept of a NavMesh. This will reduce the amount of code we need to write as well as the time taken to setup a waypoint system manually.

Preview 05:11

In this lecture we will turn the previous waypoint system with the tank into a navmesh based project.

From Waypoints to NavMesh
09:07

In this lecture we will start taking a closer look at the navmesh agent component and explore the various settings for the baked nav mesh agent that controls how the navmesh is generated.

NavMesh Agents Part 1
17:42

Agents can be assigned different areas of the NavMesh through which to travel. In this lecture we will look at how to set up different areas with different costs and associate the agents with them.

NavMesh Agents Part 2
10:32

The test of a NavMesh is to try it out with a real character in a real situation. It's then you'll find glitches in the default settings and automatically generated paths. Without having to remodel the environment, off-mesh links can be generated to provide smooth paths were their aren't any. In this lecture we will make a character follow a first person player character around a map while tweaking the NavMesh to handle different situations when gaps and drops appear in the NavMesh.

Following a Player on A NavMesh and Setting-Up Off Mesh Links
14:10

This video link describes how to fix textures on imported FBX files from Mixamo.

Fixing Mixamo Textures
00:09

In this lecture we will examine how the NavMesh agent code and be coordinated with character animation to provide smooth and believable movement of a character when pathfinding over a NavMesh.

Animating on a NavMesh
13:36

In order to include multiple navmeshes to cater for multiple different navmeshagent sizes we need to turn to some beta code that isn't currently included in Unity but available for download and inclusion. In this lecture we will walk through the setups of creating multiple navmeshes after a quick refresher on setting up humanoid animations with strafe sets.

Multiple NavMeshes for Different Agent Sizes
12:41
Challenge
00:12
+ Moving As One
10 lectures 01:39:56

There are many factors to included in a crowd simulation... or are there? Seemingly very complex movement behaviour can be generated for groups of characters with some very simple rules. This lecture will show you how.

Crowd Simulation
07:59

In this series of lectures we will set up a city scene with a crowd walking along the sidewalk.

Creating a City Crowd Part 1
12:55

This lecture continues on from the last adjusting animation behaviours and speeds to vary from agent to agent as well as introduces the concept of a dynamic obstacle that can move around a navmesh and be avoided by the agents.

Creating a City Crowd Part 2
11:20

A behaviour seen in NPC movement is fleeing. This is a technique for steering a character away from danger. In this lecture we will look at the mathematics involved in the movement and apply it to the crowd simulation.

Fleeing
18:29

Flocking is capable of producing incredible behaviour from three simple vector calculations. In this lecture you will learn how to apply this to the development of schooling fish.

Flocking Part 1
20:00

In this second part of the flocking workshop we will add extra behaviours to the fish by controlling the boundary of their swimming range.

Flocking Part 2
15:45

The third part of the flocking workshop will explore ways in which the fish can avoid obstacles in their environment through raycasting and vector calculations.

Flocking Part 3
12:58
Challenge 1
00:14
Challenge 2
00:07
Challenge 3
00:08
+ Let's Start Thinking
6 lectures 56:37

In this lecture we will develop an NPC that can detect the presence of a player and act accordingly. We will implement step-by-step this algorithm which is one of the simplest AI techniques used.

Line of Sight
14:10

Finite State Machines are a staple AI method used in games as they elegantly segregate the states, behaviours and logic used by NPCs. In part one we will begin looking at how the Unity animation system can be used to create such a machine.

Finite State Machines Part 1
10:52

In this second part of the FSM workshop we will add a base NPC class to enable sharing of properties between behaviour scripts and then add in the functionality to move from patrol to chase and back again.

Finite State Machines Part 2
14:49

In the final FSM lecture, steping you through the setup for a FSM, we will complete the example by adding in bullet shooting functionality and states onto the NPC tank.

Finite State Machines Part 3
09:36

In this short lecture I'll show you how to convert the waypoint system used to move the tank around to have the same FSM work on a navmesh.

Converting the FSM to Work on a Navmesh
07:05
Challenge
00:05
+ Behaviour Trees
8 lectures 01:17:30

In this lecture Behaviour Trees will be introduced. Well take a look at their structure and the theory of their execution.

Introduction to Behaviour Trees
03:54

This lecture begins by taking you through the setup for our behaviour tree project before starting with a very simple sequencial behaviour tree as a demo.

Sequence Nodes Part 1
17:17

We continue our examination of sequences in this lecture by creating a longer set of actions and modifying different behaviour tree specific returns discover what makes sequences run and fail. Towards the end we will start creating a new behaviour tree for attacking and take a look at the wait leaf node.

Sequence Nodes Part 2
16:06

In this lecture we will take a look at the while decorator node that allows you to invert the value of an action and also perform logic tests in the tree at a higher level than leaf nodes.

Embedding Logic in Behaviour Trees
11:00

This lecture will introduce the selector node. This type of node can be used when any (but only one) of the children nodes need to run.

Selector Nodes
05:15

In this lecture we will complete the full set of single behaviour trees that will define all behaviours of the agent by adding the abilities to flee from danger and die.

More Logic for Complex Behaviours
08:20

To finish our investigation into Behaviour Trees all the smaller trees made throughout this section will be combined to inform the total behaviour of the agent droid. A final version of the project is attached as a download.

Putting Together a Complex Behaviour Tree
15:26
Challenge
00:12
+ Goal-Orientated Action Planning
5 lectures 51:27

Goal-Orientated Action Planning is an AI technique that turns Finite State Machines on their head. It decouples goals from actions and provides for a very dynamic NPC behavioural system.

Introduction to GOAP
05:22

In this lecture we will get started with GOAP by setting up a simple scene and adding an agent.

Getting Started with GOAP in Unity
14:48

In this lecture the GOAP agent will be given its first set of actions.

11:15

To create more complex behaviours in an agent you can add multiple plans that it can execute when the world states are right. In this lecture we will do this by extending the baker behaviour.

06:51

Even more complexity can be added when multiple inventories and agents are introduced to the system. This lecture will take you through the addition of a world inventory as well as a new agent type.

Global States and Multiple Agents
13:11
Requirements
• You should be familiar with C# and the Unity Game Development Engine.
Description

Do your non-player characters lack drive and ambition?  Are they slow, stupid and constantly banging their heads against the wall?  Then this course is for you.  Join Penny as she explains, demonstrates and assists you to create your very own NPCs in Unity with C#. All you need is a sound knowledge of Unity, C# and the ability to add two numbers together.

In this course, Penny reveals the most popular AI techniques used for creating believable character behaviour in games using her internationally acclaimed teaching style and knowledge from over 25 years working with games, graphics and having written two award winning books on games AI. Through-out you will follow along with hands-on workshops designed to teach you about the fundamental AI techniques used in today's games.  You'll join in as NPCs are programmed to chase, patrol, shoot, race, crowd and much more.

Learn how to program and work with:

• vectors;
• waypoints;
• navmeshes;
• the A* algorithm;
• crowds;
• flocks;
• animated characters, and
• vehicles.

Contents and Overview

The course begins with a detailed examination of vector mathematics that sits at the very heart of programming the movement of NPCs.  Following this systems of waypoints will be used to move characters around in an environment before examining the Unity waypoint system for car racing with AI controlled cars.  This leads into an investigation of graph theory and the A* algorithm before we apply these principles to developing navmeshes and developing NPCs who can find their way around a game environment.  Before an aquarium is programmed complete with autonomous schooling fish, crowds of people will be examined from the recreation of sidewalk traffic to groups of people fleeing from danger. Having examined the differing ways to move NPCs around in a game environment their thinking abilities will be discussed with full explanations and more hands-on workshops in finite state machines and behaviour trees.

The follow-along workshops included in the course come with starter Unity asset files and projects complete with solutions.  Throughout there are also quizzes and challenge exercises to reinforce your learning and to guide you to express your new found knowledge.

At the completion of this course you will have gained a broad understanding of what AI is in games, how it works and how you can use it in your own projects.  It will equip you with a toolset to examine any of the techniques presented in more depth to take your game environments to the next level.