Esempio n. 1
0
    private void Update()
    {
        float steerAmount = Input.GetAxis("Horizontal") * steeringAngle;
        float powerAmount = Input.GetAxis("Vertical") * acceleration;

        if (powerAmount < 0.0f)
        {
            // brake
            controller.Brake(powerAmount * brakeFactor);
        }
        else if (powerAmount > 0.0f)
        {
            // accelerate
            controller.Power(powerAmount);
        }
        else
        {
            controller.Coast();
        }

        controller.Steer(steerAmount);
    }