void OnDestroy() { if (updateRoutine != null) { StopCoroutine(updateRoutine); } if (stateMachine != null) { stateMachine.Destroy(); stateMachine = null; } }