// Update is called once per frame void Update() { // different key codes when running... if (running) { if (Input.GetKeyUp(KeyCode.C)) { // Circularize (if in the vicinity of the moon) CircularizeAroundMoon(); } else if (Input.GetKeyUp(KeyCode.R)) { // Raise circular orbit but Hohmann Xfer NewCircularOrbit(1.3f); } return; } bool doUpdate = UpdateManeuverSymbols(); // Stop GE once it has started if (ge.GetEvolve() && !running) { ge.UpdatePositionAndVelocity(shipEnterSOI, targetPoint.ToVector3(), Vector3.zero); ge.SetEvolve(false); doUpdate = true; } doUpdate |= AdjustTimeOfFlight(); if (Input.GetKeyUp(KeyCode.X)) { // execute the transfer ExecuteTransfer(); if (instructions != null) { instructions.gameObject.SetActive(false); } // HACK toMoonOrbit.gameObject.SetActive(true); toMoonOrbit.velocityFromScript = false; } else if (Input.GetKeyUp(KeyCode.Space)) { ge.SetEvolve(!ge.GetEvolve()); } else { doUpdate |= HandleMouseSOIInput(); } if (doUpdate) { // Orbit predictor gets an explicit velocity, so no need to set here Vector3 tliVelocity = ComputeTransfer(); // false - ignore inclination for scene display SetOrbitDisplays(true); // move ship to position, with correct velocity ge.UpdatePositionAndVelocity(spaceship, startPoint.ToVector3(), tliVelocity); } }
// Update is called once per frame void Update() { if (!frame1Hack) { frame1Hack = true; AddGhostBodies(); ComputeBaseTransferTime(); // need GE to process these updates Debug.LogFormat("Moon period={0:0.0}", ghostMoonOrbit[MOON_SOI_ENTER].GetPeriod()); } if (!running) { // Getting user input for FR AdjustTimeOfFlight(); UpdateManeuverSymbols(); HandleMouseSOIInput(); ComputeTransfer(); if (freeReturnInfo != null) { freeReturnInfo.text = string.Format("Perilune = {0:0.0}\nReturn Perigee={1:0.0}\nTime to SOI = {2:0.0}\n{3}", ghostShipOrbit[SOI_HYPER].GetPerigee(), ghostShipOrbit[EXIT_SOI].GetPerigee(), timeHohmann * tflightFactor, GravityScaler.GetWorldTimeFormatted(timeHohmann * tflightFactor, ge.units)); } } else { // RUNNING if (Input.GetKeyUp(KeyCode.C)) { // Circularize (if in the vicinity of the moon) CircularizeAroundMoon(); } else if (Input.GetKeyUp(KeyCode.R)) { // Raise circular orbit but Hohmann Xfer NewCircularOrbit(1.3f); } return; } if (Input.GetKeyUp(KeyCode.X)) { // execute the transfer ExecuteTransfer(); if (instructions != null) { instructions.gameObject.SetActive(false); } running = true; } else if (Input.GetKeyUp(KeyCode.Space)) { ge.SetEvolve(!ge.GetEvolve()); } }