Using an FSM framework
The FSM framework we're going to use here is adapted from the Deterministic Finite State Machine framework, based on Chapter 3.1 of Game Programming Gems 1 by Eric Dybsend. We'll only be looking at the differences between this FSM and the one we made earlier. For this reason, it is important that you follow the example code found in the Chapter02
folder of the book repository (https://github.com/PacktPublishing/Unity-Artificial-Intelligence-Programming-Fifth-Edition). In particular, we will look at the AdvancedFSM scene.
In this section, we will study how the framework works and how we can use this to implement our tank AI. AdvancedFSM
and FSMState
are the two main classes of our framework. So, let's take a look at them first.
The AdvancedFSM class
The AdvancedFSM
class manages all the FSMState
classes we've implemented and keeps them updated with the transitions and the current state. So, the first thing to do before using our framework...