// TOGGLE SPACEBAR TO STOP / START SHIP MOVEMENT public void StopShip() { // null check prevents checking more than once if (spaceflight == null) { spaceflight = FindObjectOfType <Spaceflight>(); // a little slow, store a reference later by passing in the game object } if (Input.GetKeyDown("space")) { if (!noMovement) { spaceflight.MaxSpeed = 0.0f; // a hacky way of stopping the ship } if (noMovement) { spaceflight.MaxSpeed = 200.0f; // a hacky way of stopping the ship } noMovement = !noMovement; // toggle the engine sound if (noMovement && !empty) { engineAudioSource.GetComponent <AudioSource>().Stop(); } if (!noMovement && !empty) { engineAudioSource.GetComponent <AudioSource>().Play(); } } }
private void Start() { // load the astronaut from resources // astronaut = Instantiate(Resources.Load("Astronaut") as GameObject); spaceflight = FindObjectOfType <Spaceflight>(); // we should start with putting the ship into stationary mode as the gameplay starts spaceflight.MaxSpeed = 0.0f; // StartCoroutine(FadeSound.FadeOut(engineAudioSource, 1f)); TODO fade out sounds }
private void Start() { spaceflight = FindObjectOfType <Spaceflight>(); shipControls = FindObjectOfType <ShipControls>(); }