/// <summary> /// Skidmarks. /// </summary> private void SkidMarks(){ // Forward, sideways, and total slips. if (isGrounded) { wheelSlipAmountForward = Mathf.Abs (wheelHit.forwardSlip); wheelSlipAmountSideways = Mathf.Abs (wheelHit.sidewaysSlip); } else { wheelSlipAmountForward = 0f; wheelSlipAmountSideways = 0f; } totalSlip = Mathf.Lerp(totalSlip, ((wheelSlipAmountSideways + wheelSlipAmountForward) / 2f), Time.fixedDeltaTime * 5f); // If scene has skidmarks manager... if(!RCCSettings.dontUseSkidmarks){ // If slips are bigger than target value... if (totalSlip > physicsFrictions [groundIndex].slip){ Vector3 skidPoint = wheelHit.point + 2f * (rigid.velocity) * Time.deltaTime; if (rigid.velocity.magnitude > 1f) lastSkidmark = skidmarksManager.AddSkidMark (skidPoint, wheelHit.normal, totalSlip - physicsFrictions [groundIndex].slip, lastSkidmark, groundIndex); else lastSkidmark = -1; }else{ lastSkidmark = -1; } } }
// Creating skidmarks. void SkidMarks() { // First, we are getting groundhit data. WheelHit GroundHit; wheelCollider.GetGroundHit(out GroundHit); // Forward, sideways, and total slips. wheelSlipAmountForward = Mathf.Abs(GroundHit.forwardSlip); wheelSlipAmountSideways = Mathf.Abs(GroundHit.sidewaysSlip); totalSlip = Mathf.Lerp(totalSlip, ((wheelSlipAmountSideways + wheelSlipAmountForward) / 2f), Time.fixedDeltaTime * 5f); // If scene has skidmarks manager... if (!RCCSettings.dontUseSkidmarks) { // If slips are bigger than target value... if (totalSlip > physicsFrictions [groundIndex].slip) { Vector3 skidPoint = GroundHit.point + 2f * (rigid.velocity) * Time.deltaTime; if (rigid.velocity.magnitude > 1f) { lastSkidmark = skidmarksManager.AddSkidMark(skidPoint, GroundHit.normal, totalSlip - physicsFrictions [groundIndex].slip, lastSkidmark, groundIndex); } else { lastSkidmark = -1; } } else { lastSkidmark = -1; } } }