// Update is called once per frame
    void Update()
    {
        if (transform.position.y < waterHeight)
        {
            GameLose(true);
        }

        //check if we need to show the controls
        if (gameStart)
        {
            if (timeText + controlShowTime < Time.time)
            {
                controls.enabled = false;
                camera.GetComponent <Camera>().clearFlags = CameraClearFlags.Skybox;
                car.ControlsOver();

                if (!timerStart)
                {
                    timer            = Time.time;
                    timerStart       = true;
                    timeLeft.enabled = true;
                }
            }
        }

        if (Input.GetKeyDown(KeyCode.Escape))
        {
            Time.timeScale = 0;
            car.Pause();
            pauseMenu.enabled = true;
            camera.GetComponent <CameraController>().AllowCameraMovement(false);
        }

        if (mode == MODE.FLY)
        {
            Quaternion rot = Quaternion.Euler(0, 0, 0);
            transform.rotation = rot;

            float moveU = 0, moveD = 0, moveFB = 0, moveLR;

            moveFB = Input.GetAxis("Vertical");
            moveLR = Input.GetAxis("Horizontal");
            moveU  = Input.GetAxis("Up");
            moveD  = Input.GetAxis("Down");

            Vector3 move = new Vector3(moveLR * 6, moveU * 4 - moveD * 4, moveFB * 6);

            transform.Translate(move * speed * Time.deltaTime);
            transform.rotation = camera.transform.rotation;
        }
        //check if we are in the game and if the controls are no longer being shown
        else if (mode == MODE.REGULAR && !controls.enabled && !gameEnd)
        {
            //check if the timer length has elapsed
            if (timer + timerLength < Time.time)
            {
                GameLose(false);
            }

            timeLeft.text = "Time: " + Math.Round((timer + timerLength) - Time.time, 1);

            float yaw = 0;
            yaw += 2 * Input.GetAxis("Mouse X");
            float moveH = Input.GetAxis("Horizontal");
            float moveV = Input.GetAxis("Vertical");
            float jump  = 0;
            if (Input.GetKeyDown(KeyCode.Space))
            {
                jump  = 1;
                inAir = true;
            }

            verticalSpeed  -= gravity * Time.deltaTime;
            verticalOffset += verticalSpeed * Time.deltaTime;
            Vector3 move;

            /*if (inAir)
             * {
             *  move = new Vector3(moveH, gravity * Time.deltaTime, moveV);
             * }
             * else
             * {*/
            move = new Vector3(moveH, jump * jumpImpulse, moveV);
            //}
            //transform.Rotate(0,moveH,0);

            //transform.Translate(move * speed * Time.deltaTime);
            //rb.AddForce(Vector3.up * jump);

            rb.AddForce(move * speed);
            //transform.forward += new Vector3(moveH, 0, 0);
        }
    }