Making decisions with FSMs
We explored the concept of Finite State Machines (FSMs) in the past when we used them in the Animator
component. We learned that an FSM is a collection of states, each one representing an action that an object can be executing at a time, and a set of transitions that dictates how the states are switched. This concept is not only used in animation but in a myriad of programming scenarios, and one of the common ones is AI. We can just replace the animations with AI code in the states and we have an AI FSM.
In this section, we will examine the following AI FSM concepts:
- Creating the FSM in C#
- Creating transitions
- Creating the FSM in Visual Scripting
Let’s start by creating our FSM skeleton.
Creating the FSM in C#
To create our own FSM, we need to recap some basic concepts. Remember that an FSM can have a state for each possible action it can execute and that only one can be executed at a time.
In terms...