// Update is called once per frame void Update() { // if (Countdown.endGame) { if (Input.anyKeyDown) { Countdown.endGame = false; SceneManager.LoadScene(0); } return; } //If not grabbed wreckage, enable controls if (!grabbedWreckage && !isAnimating) { float vel = Input.GetAxis(ThrustButton); rigidBody.AddRelativeForce(new Vector2(0, vel * stats.GetAcceleration())); if (vel != 0 && !engineOn) { //Turn Engine on audioSource.clip = engineRunning; audioSource.Play(); particle.Play(); engineOn = true; } else if (vel == 0 && engineOn) { //Turn engine off audioSource.clip = engineIdle; audioSource.Play(); particle.Stop(); engineOn = false; } transform.Rotate(0, 0, -Input.GetAxis(TurnButton) * stats.GetTurningSpeed()); } if (Input.GetButtonDown(GrabButton)) { GrabObject(); } if (Input.GetButtonDown(ShootButton)) { Shoot(); } Vector2 dir = rigidBody.velocity.normalized; float mag = rigidBody.velocity.magnitude; rigidBody.velocity = dir * Mathf.Min(mag, stats.GetMaxSpeed()); }