Non-Player Characters (NPC) are components in games that can be used to create interactions and gameplay dynamics. NPC behavior control is required to enable characters to respond appropriately to conditions occurring during gameplay. This study aims to implement a Finite State Machine (FSM) to control customer NPC behavior in the Unity-based 2D game Cooking Chaos. The implemented FSM consists of four states: Waiting, Angry, Chasing, and Attack. State transitions are influenced by the customer’s patience system and interaction conditions with the player. When the patience time expires, the customer changes behavior from waiting to becoming angry, chasing, and potentially attacking the player. The implementation was evaluated using Black Box Testing, FSM Transition Testing, and Multi-Customer Testing. The Black Box Testing results showed that all 12 functional scenarios were valid. FSM Transition Testing on seven scenarios, each tested 10 times, resulted in 70 successful trials out of 70. Multi-Customer Testing demonstrated that the order, patience, and FSM mechanisms operated independently with up to three active customers simultaneously. The results indicate that the implemented FSM consistently controls customer NPC behavior transitions under the defined test scenarios and integrates the service mechanism with direct gameplay consequences for the player.
Copyrights © 2026