Demo9b: Using an FSM and BT to control the NPC
Demo9b
builds upon the foundation of Demo9a
adding new elements to enhance the gameplay. In this demo, the player can control the protagonist to move around and attack. Additionally, an NPC is introduced on the battlefield. The NPC leverages a BT to determine its actions, such as remaining in the guard state, going to the player, or attacking the player. Its animation transitions are seamlessly managed using an FSM.
Let’s explore a typical gameplay scenario to understand the NPC’s behavior. Initially, the NPC remains stationary, observing its surroundings. When the player character enters the NPC’s vision range, the NPC transitions into pursuit mode, running toward the player to close the distance and move within attack range to launch an attack. However, if the player character successfully leaves the NPC’s vision range, the NPC halts its pursuit and returns to its guard state. This scenario highlights...