Exemplo n.º 1
0
    void OnEnable()
    {
        animationManager = gameObject.GetComponent <VehicleAnimationManager>();
        rb         = gameObject.GetComponent <Rigidbody>();
        headlights = gameObject.GetComponent <CarHeadlights>();

        initialPosition = transform.position;
        initialRotation = transform.rotation;

        RecalcDrivingWheels();

        tractionControlAdjustedMaxTorque = maxMotorTorque - (tractionControlAmount * maxMotorTorque);

        axles[0].left.ConfigureVehicleSubsteps(5.0f, 30, 10);
        axles[0].right.ConfigureVehicleSubsteps(5.0f, 30, 10);
        axles[1].left.ConfigureVehicleSubsteps(5.0f, 30, 10);
        axles[1].right.ConfigureVehicleSubsteps(5.0f, 30, 10);

        foreach (var axle in axles)
        {
            axle.left.wheelDampingRate  = wheelDamping;
            axle.right.wheelDampingRate = wheelDamping;
        }

        ambientTemperatureK = zeroK + 22.0f; // a pleasant 22° celsius ambient
        engineTemperatureK  = zeroK + 22.0f;

        lastRBPosition = rb.position;
    }