示例#1
0
 // Start is called before the first frame update
 void Start()
 {
     audioSource      = GetComponent <AudioSource>();
     wheel            = GetComponent <WheelColliderAdv>();
     audioSource.clip = audioTireSqueal;
     audioSource.loop = true;
     audioSource.Play();
 }
示例#2
0
    public CWWheelTorqueDistr(WheelColliderAdv _wheelColliderAdv, CWWheel _wheel, Rigidbody rigidbody, CWPacejka cWPacejka, bool _hasMotor)
    {
        wheelColliderAdv = _wheelColliderAdv;
        wheel            = _wheel;
        rb       = rigidbody;
        pacejka  = cWPacejka;
        hasMotor = _hasMotor;

        //Start
        wheelMass   = wheel.WheelMass;
        wheelRadius = wheel.Radius;
        J           = wheelMass * wheelRadius * wheelRadius * 0.5f;

        slowdownFac       *= (wheelMass / 15f);
        slowdownFacDamper *= (wheelMass / 15f);
    }
示例#3
0
    public CWWheel(WheelColliderAdv _wheelColliderAdv, Transform _transform, Rigidbody rigidbody, CWPacejka pacejkaParam,
                   Transform wheelMeshParam, float _restLength, float _springTravel, float _springStiffness, float _springDamping, float _wheelRadius, float _wheelMass)
    {
        wheelColliderAdv = _wheelColliderAdv;
        transform        = _transform;
        wheelMesh        = wheelMeshParam;
        rb      = rigidbody;
        pacejka = pacejkaParam;

        restLength      = _restLength;
        springTravel    = _springTravel;
        springStiffness = _springStiffness;
        springDamping   = _springDamping;
        wheelRadius     = _wheelRadius;
        wheelMass       = _wheelMass;

        maxWheelVelocity    = 20f;
        maxWheelVelocityAcc = 10f;
        antiRollStiffness   = 0f;
        applyForceGround    = true;
        smoothStep          = true;

        slowCorrectionStart = 0.11f;
        slowCorrectionForce = 0.1f;

        wheelSphereJumpThreshold         = 0.05f;
        wheelSphereJumpMaxAngle          = 30f;
        wheelSphereJumpMinAngleNormals   = 5f;
        wheelSphereJumpMinGroundTime     = 0f;
        wheelSphereJumpNormalDistanceMin = 0.05f;
        wheelMaxForce = 10000000f;
        wheelMaxA     = 10f;

        angularVelocity = 0f;
        fcSide          = 1f;



        //Start

        minLength = restLength - springTravel;
        maxLength = restLength + springTravel;

        springLength    = restLength;
        springLength    = Mathf.Clamp(springLength, minLength, maxLength);
        springLengthOld = springLength;

        if (smoothStep)
        {
            GameObject instSphere = null;
            if (wheelSphere == null)
            {
                instSphere = new GameObject("(Inst) Car Sphere");
            }
            else
            {
                instSphere = wheelSphere.gameObject;
            }
            CapsuleCollider sc = instSphere.AddComponent <CapsuleCollider>();
            sc.radius              = 0.5f;
            sc.direction           = 0;
            sc.height              = 3f;
            wheelSphere            = instSphere.transform;
            wheelSphere.localScale = new Vector3(wheelRadius * 2f, wheelRadius * 2f, wheelRadius * 2f);

            wheelSphere.position = new Vector3(0f, -10000f, 0f);
        }
    }