Пример #1
0
    void Update()
    {
        if (drivable)
        {
            acceleration = Input.GetAxis("Vertical") * torque;
            steering     = maxSteeringAngle * Input.GetAxis("Horizontal");
            if (acceleration < 0)
            {
                foreach (Light brakelight in brakelights)
                {
                    brakelight.enabled = true;
                }
            }
            else if (!handBraking)
            {
                foreach (Light brakelight in brakelights)
                {
                    brakelight.enabled = false;
                }
            }
            // Handbrake
            if (Input.GetButtonDown("Brake") && grounded && !handBraking && moveSpeed > 0.5f)
            {
                HandBraking();
            }
            else if (Input.GetButtonUp("Brake") || !grounded)
            {
                StopHandBraking();
            }
        }

        if (Input.GetKeyDown(KeyCode.Return) || Input.GetKeyDown(KeyCode.JoystickButton0) && !skipCountdown)
        {
            cam.ActivateCamera();
            lm.skipCountdown = true;
            skipCountdown    = true;
        }

        AngleCheck();
        GroundCheck();
        SteeringCheck();
        AirControl();


        if (boosting)
        {
            boostTimeLeft -= Time.deltaTime;
            if (boostTimeLeft < 0)
            {
                boosting = false;
                boostParticles.GetComponent <ParticleSystem>().Stop();
            }
        }
        UpdateDashboardVisuals();
    }