// Start is called before the first frame update void Start() { if (customPacejka == null) { Debug.LogWarning("You need to assign a Pacejka. Using a default one"); GameObject pacObj = new GameObject("Pacejka"); pacObj.AddComponent <CWPacejka>(); customPacejka = pacObj.GetComponent <CWPacejka>(); } if (carRigidbody == null) { Debug.LogWarning("No Rigidbody was assigned. Chose one in parent"); carRigidbody = GetComponentInParent <Rigidbody>(); if (carRigidbody == null) { Debug.LogError("No Rigidbody was found. You need a rigidbody in one of the parent objects"); } } if (wheelMesh == null) { //Debug.LogWarning("No wheel mesh was found"); } cwWheel = new CWWheel(this, transform, carRigidbody, customPacejka, wheelMesh, restLength, springTravel, springStiffness, springDamping, wheelRadius, wheelMass); cwWheelTorqueDistr = new CWWheelTorqueDistr(this, cwWheel, carRigidbody, customPacejka, hasMotor); cwWheel.torqueDistr = cwWheelTorqueDistr; cwWheel.debugMessages = debugMessages; }
// Start is called before the first frame update void Start() { GameObject skidObj = new GameObject("Skidmarks"); skidmarksController = skidObj.AddComponent <Skidmarks>(); skidmarksController.skidmarksMaterial = skidMaterial; if (skidmarksController == null) { Debug.LogError("No Skidmarks found in scene"); } wheel = GetComponent <WheelColliderAdv>().CWWheel; }
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); }