void FixedUpdate() { if (skidmarks) { WheelHit GroundHit; wheel_col.GetGroundHit(out GroundHit); wheelSlipAmountSideways = Mathf.Abs(GroundHit.sidewaysSlip); wheelSlipAmountForward = Mathf.Abs(GroundHit.forwardSlip); if (wheelSlipAmountSideways > startSlipValue || wheelSlipAmountForward > .5f) { Vector3 skidPoint = GroundHit.point + 2f * (vehicleRigid.velocity) * Time.deltaTime; if (vehicleRigid.velocity.magnitude > 1f) { lastSkidmark = skidmarks.AddSkidMark(skidPoint, GroundHit.normal, (wheelSlipAmountSideways / 2f) + (wheelSlipAmountForward / 2.5f), lastSkidmark); } else { lastSkidmark = -1; } } else { lastSkidmark = -1; } } }
void FixedUpdate() { if (skidmarks) { WheelHit GroundHit; wheelCollider.GetGroundHit(out GroundHit); wheelSlipAmountSideways = Mathf.Abs(GroundHit.sidewaysSlip); wheelSlipAmountForward = Mathf.Abs(GroundHit.forwardSlip); if (wheelSlipAmountSideways > startSlipValue || wheelSlipAmountForward > .5f) { Vector3 skidPoint = GroundHit.point + 2f * (carRigid.velocity) * Time.deltaTime; if (carRigid.velocity.magnitude > 1f) { lastSkidmark = skidmarks.AddSkidMark(skidPoint, GroundHit.normal, (wheelSlipAmountSideways / 2f) + (wheelSlipAmountForward / 2.5f), lastSkidmark); } else { lastSkidmark = -1; } } else { lastSkidmark = -1; } } WheelHit hit; wheelCollider.GetGroundHit(out hit); if (wheelCollider.GetGroundHit(out hit)) { if (carController._groundMaterial == RCCCarControllerV2.GroundMaterial.Asphalt && carController.asphaltPhysicsMaterial) { forwardFrictionCurve.stiffness = carController.asphaltPhysicsMaterial.staticFriction * 1.666f; sidewaysFrictionCurve.stiffness = carController.asphaltPhysicsMaterial.staticFriction * 1.666f; } else if (carController._groundMaterial == RCCCarControllerV2.GroundMaterial.Grass && carController.grassPhysicsMaterial) { forwardFrictionCurve.stiffness = carController.grassPhysicsMaterial.staticFriction * 1.666f; sidewaysFrictionCurve.stiffness = carController.grassPhysicsMaterial.staticFriction * 1.666f; } else if (carController._groundMaterial == RCCCarControllerV2.GroundMaterial.Sand && carController.sandPhysicsMaterial) { forwardFrictionCurve.stiffness = carController.sandPhysicsMaterial.staticFriction * 1.666f; sidewaysFrictionCurve.stiffness = carController.sandPhysicsMaterial.staticFriction * 1.666f; } else if (carController.asphaltPhysicsMaterial) { forwardFrictionCurve.stiffness = carController.asphaltPhysicsMaterial.staticFriction * 1.666f; sidewaysFrictionCurve.stiffness = carController.asphaltPhysicsMaterial.staticFriction * 1.666f; } else { forwardFrictionCurve.stiffness = 1f; sidewaysFrictionCurve.stiffness = 1f; } if (carController._wheelTypeChoise == RCCCarControllerV2.WheelType.DRIFT) { if (wheelCollider == carController.FrontLeftWheelCollider || wheelCollider == carController.FrontRightWheelCollider) { sidewaysFrictionCurve.asymptoteValue = .75f; } else { forwardFrictionCurve.asymptoteValue = 1f; sidewaysFrictionCurve.asymptoteValue = .65f; } } wheelCollider.forwardFriction = forwardFrictionCurve; wheelCollider.sidewaysFriction = sidewaysFrictionCurve; } }
void FixedUpdate() { if (skidmarks) { WheelHit GroundHit; wheelCollider.GetGroundHit(out GroundHit); wheelSlipAmountSideways = Mathf.Abs(GroundHit.sidewaysSlip); wheelSlipAmountForward = Mathf.Abs(GroundHit.forwardSlip); if (wheelSlipAmountSideways > startSlipValue || wheelSlipAmountForward > .5f) { Vector3 skidPoint = GroundHit.point + 2f * (carRigid.velocity) * Time.deltaTime; if (carRigid.velocity.magnitude > 1f) { lastSkidmark = skidmarks.AddSkidMark(skidPoint, GroundHit.normal, (wheelSlipAmountSideways / 2f) + (wheelSlipAmountForward / 2.5f), lastSkidmark); } else { lastSkidmark = -1; } } else { lastSkidmark = -1; } } RaycastHit hit; if (Physics.Raycast(transform.position, -transform.up, out hit)) { if (carController.UseTerrainSplatMapForGroundPhysic && hit.transform.gameObject.GetComponent <TerrainCollider>()) { if (TerrainSurface.GetTextureMix(transform.position)[0] > .5f) { SetWheelStiffnessByGroundPhysic(1f); } else if (TerrainSurface.GetTextureMix(transform.position)[1] > .5f) { SetWheelStiffnessByGroundPhysic(2f); } else if (TerrainSurface.GetTextureMix(transform.position)[2] > .5f) { SetWheelStiffnessByGroundPhysic(3f); } return; } if (hit.collider.material.name == grassPhysicsMaterial.name + " (Instance)") { SetWheelStiffnessByGroundPhysic(3f); } else if (hit.collider.material.name == sandPhysicsMaterial.name + " (Instance)") { SetWheelStiffnessByGroundPhysic(2f); } else { SetWheelStiffnessByGroundPhysic(1f); } } }