void Start() { tr = transform; rb = (Rigidbody)F.GetTopmostParentComponent <Rigidbody>(tr); vp = (VehicleParent)F.GetTopmostParentComponent <VehicleParent>(tr); targetDrive = GetComponent <DriveForce>(); flippedSide = Vector3.Dot(tr.forward, vp.transform.right) < 0; flippedSideFactor = flippedSide ? -1 : 1; initialRotation = tr.localRotation; if (Application.isPlaying) { GetCamber(); //Generate the hard collider if (generateHardCollider) { GameObject cap = new GameObject("Compress Collider"); cap.layer = GlobalControl.ignoreWheelCastLayer; compressTr = cap.transform; compressTr.parent = tr; compressTr.localPosition = Vector3.zero; compressTr.localEulerAngles = new Vector3(camberAngle, 0, -casterAngle * flippedSideFactor); compressCol = cap.AddComponent <CapsuleCollider>(); compressCol.direction = 1; setHardColliderRadiusFactor = hardColliderRadiusFactor; hardColliderRadiusFactorPrev = setHardColliderRadiusFactor; compressCol.radius = wheel.rimWidth * hardColliderRadiusFactor; compressCol.height = (wheel.popped ? wheel.rimRadius : Mathf.Lerp(wheel.rimRadius, wheel.tireRadius, wheel.tirePressure)) * 2; compressCol.material = GlobalControl.frictionlessMatStatic; } steerRangeMax = Mathf.Max(steerRangeMin, steerRangeMax); properties = GetComponent <SuspensionPropertyToggle>(); if (properties) { UpdateProperties(); } } }
void Start() { tr = transform; rb = transform.root.GetComponent<Rigidbody>(); vp = tr.root.GetComponent<VehicleParent>(); targetDrive = GetComponent<DriveForce>(); flippedSide = Vector3.Dot(tr.forward, tr.root.right) < 0; flippedSideFactor = flippedSide ? -1 : 1; initialRotation = tr.localRotation; if (Application.isPlaying) { GetCamber(); //Generate the hard collider if (generateHardCollider) { GameObject cap = new GameObject("Compress Collider"); cap.layer = GlobalControl.ignoreWheelCastLayer; compressTr = cap.transform; compressTr.parent = tr; compressTr.localPosition = Vector3.zero; compressTr.localEulerAngles = new Vector3(camberAngle, 0, -casterAngle * flippedSideFactor); compressCol = cap.AddComponent<CapsuleCollider>(); compressCol.direction = 1; setHardColliderRadiusFactor = hardColliderRadiusFactor; hardColliderRadiusFactorPrev = setHardColliderRadiusFactor; compressCol.radius = wheel.rimWidth * hardColliderRadiusFactor; compressCol.height = (wheel.popped ? wheel.rimRadius : Mathf.Lerp(wheel.rimRadius, wheel.tireRadius, wheel.tirePressure)) * 2; compressCol.material = GlobalControl.frictionlessMatStatic; } steerRangeMax = Mathf.Max(steerRangeMin, steerRangeMax); properties = GetComponent<SuspensionPropertyToggle>(); if (properties) { UpdateProperties(); } } }