My AI script is split into multiple parts, there’s a script to handle animations inputs, one for visual and audio detection and the final one for its behavior, the AIBrain.
The AI plays the surprise animation as it transistions to the chase state
Since i’m treating this version of the AI script as an experimental script for prototyping, not a final product, I decided to try out making it with a coroutine based state machine. While this made certain elements, like constant detection inputs, more difficult to mange it had some major pros in that it allowed me to give each state a linear intro sequence of events, a looping middle, and a linear outro.
This allowed for very directed transition between states that allowed me to give my patroller some specific behaviors, beyond immediately responding to new inputs.