Unity advanced development-FSM finite state machine
Unity advanced development-FSM finite state machine # Unity advanced development-FSM finite state machine Foreword When we develop, to a certain extent, we will encounter dozens of states. If we continue to use Unity’s Animator controller, a large number of bool and float type variables will appear, and these intricate variables are just like the Animatator controller. The combination of maze version connections will become extremely complex and cannot be well maintained and expanded. The emergence of a BUG will cause developers to bear great mental strength during the development process. At this time, using finite state machines or AI behavior trees becomes An excellent choice, This article only records the development of finite state machines Using finite state machines for state management and switching can greatly reduce the difficulty of development. During the development process, you only need to pay attention to the switching between each state Illustration of FSM working process: We can see that the FSM script is divided into two large parts, one of which is inherited from IState, which stores the behaviors executed in the state, such as entering the state, leaving the state, and logical switching (used to determine whether to switch to other states),…