A state machine implementation for unity3D