public void Move(Movable.Move move, int steps, bool schedule = false) { if (GetComponent <Battery>().CurrentEnergy > 0f && movable.enabled) { CurrentState = RobotSphereState.Walk; if (schedule) { movable.ScheduleMove(move, steps); } else { movable.MoveOnces[(int)move](steps); } } }
private void RobotSphereUpdate() { if (Input.GetKey(KeyCode.Q)) { scriptActive = false; movable.enabled = true; movable.ClearSchedule(); } //Block user input when editor is up if (UIManager.Get <CodeEditorViewModel>()?.IsActive ?? false) { return; } // update animation at beginning to ensure consistency animator.Update(CurrentState); CurrentState = cc.velocity.magnitude < float.Epsilon || GetComponent <Battery>().CurrentEnergy <= 0f ? RobotSphereState.Idle : RobotSphereState.Walk; if (scriptActive) { ExecuteScript(); } else { fpsController.Update(); } if (CurrentState == RobotSphereState.Walk) { time += Time.deltaTime; fpsCamera.transform.localPosition = new Vector3(Mathf.Sin(time * 8f) * 0.02f, 0.1f + Mathf.Sin(time * 16f) * 0.02f, 0.07f); if (!Walk.isPlaying) { Walk.Play(); } } }