Making decisions with FSMs
We explored the concept of Finite State Machines (FSMs) when we used them in the Animator. 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 dictate how the states are switched. This concept is not only used in Animation but in a myriad of programming scenarios, and one of the most common ones is in AI. We can just replace the animations with AI code in the states to get 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 FSM, we need to recap on 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 of AI, we can be Patrolling, Attacking...