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)

An overview of behavior trees


For game AI, we need to define logic for the different AI entity characters in the game, that is, how they will act and react to different things in the game environment. The traditional and simpler way to do this is to use Finite State Machines (FSMs). In this approach, each character can be in a distinct state, and an FSM is a graph that defines states (nodes) and their transitions (edges). A simple example would be an enemy entity with two states, patrol and attack. The FSM will start in a patrol state, and when it gets close to a player, it transitions to an attack state. FSMs work for very simple state setups such as this, but they don't scale well, as the states and transitions have to be manually configured, usually through code. What if instead of the two states, our enemy character was more realistic and had 10 or even 100 different states, with many transitions between each? This becomes very difficult to manage and implement.

The popular alternative...