private void CheckForWheelSpin() { for (int i = 0; i < 4; i++) { wheel = car.wheels[i]; wheelEffects = wheel.wheelCollider.GetComponent <WheelEffects>(); if (wheelEffects == null) { continue; } if (!wheel.wheelCollider.isGrounded) { wheelEffects.EndSkidTrail(); } // is the tire slipping above the given threshhold if ( Mathf.Abs(wheel.slipRatio) > car.m_SlipLimit + 0.1f // || //Mathf.Abs(wheel.wheelCollider.GetGroundHit.sidewaysSlip) > car.m_SlipLimit + 0.1f ) { wheelEffects.EmitTyreSmoke(); // avoiding all four tires screeching at the same time // if they do it can lead to some strange audio artefacts if (!AnySkidSoundPlaying()) { if (carAudio.camDist < carAudio.maxRolloffDistance * carAudio.maxRolloffDistance) { wheelEffects.PlayAudio(); } } continue; } // if it wasnt slipping stop all the audio if (wheelEffects.PlayingAudio) { wheelEffects.StopAudio(); } // end the trail generation wheelEffects.EndSkidTrail(); } }
private void CheckForWheelSpin() { for (int i = 0; i < 4; i++) { wheel = car.wheels[i]; wheelEffects = wheel.wheelCollider.GetComponent <WheelEffects>(); if (wheelEffects == null) { continue; } // is the tire slipping above the given threshhold if (wheel.wheelCollider.isGrounded && Mathf.Abs(wheel.slipRatio) > wheel.wheelCollider.forwardFriction.extremumSlip + 0.3f && Mathf.Abs(wheel.speedInKmH - wheel.m_Car.speedInKmH) > 1 // || //Mathf.Abs(wheel.wheelCollider.GetGroundHit.sidewaysSlip) > car.m_SlipLimit + 0.1f ) { wheelEffects.EmitTyreSmoke(); // avoiding all four tires screeching at the same time // if they do it can lead to some strange audio artefacts if (!AnySkidSoundPlaying()) { if (carAudio.camDist < carAudio.maxRolloffDistance * carAudio.maxRolloffDistance) { wheelEffects.PlayAudio(); } } } else { stopEffect(wheelEffects); } } }