private State CreateFiringState() { var firing = _stateMachine.CreateState(States.Firing); firing.onEnter = delegate { Debug.Log($"Entering state {firing.id}"); _animator.SetInteger("state", (int)firing.id); _mover.IsStopped = true; }; firing.onFrame = delegate { var hitObject = _scanner.FireScan(_target); if (hitObject == null) { _target = hitObject; _stateMachine.TransitionTo(States.Scouting); } else { if ((Time.time - timeOfLastBulletFired) > _timeBetweenShots) { Fire(); } _mover.FireMove(_target); } }; firing.onExit = delegate { Debug.Log($"Exiting state {firing.id}"); }; return(firing); }