{{{ #!Markdown # CarVisuals Provides the visual effects for the wheels, including suspension, rotation, steering, skidmarks and smoke. This is script is added at the root GameObject for the vehicle, together with the [CarControl](wiki:CarControl) script. The script needs a global __Skidmarks__ object to be present at the scene. Use the Skidmarks prefab from the Prebafs folder. The Skidmarks object has a child object __SkidSmoke__ which provides the particle emitter and renderer for the smoke effects. #### PivotFL, PivotFR, PivotRL, PivotRR References to the pivot GameObjects for each wheel. Each __pivot__ GameObject is located at the vehicle's local position for each wheel. Pivots will be moved vertically (suspension) and the front ones will be rotated around their local Y axis (steering). These GameObjects are the proper placeholders for _disc brake_ meshes, which doesn't rotate with the wheel but respond to suspension and steering (example: Sport Coupe). If no disc brakes are used in the model, then use empty GameObjects (example: Bus). #### MeshFL, MeshFR, MeshRL, MeshRR References to the GameObjects representing each wheel and tire. These are the 3D meshes for the wheels. These GameObjects must be child of their respective pivots. They will be rotated around X axis as the normal wheel rotation when the vehicle moves. #### Steering wheel A reference to the GameObject containing the steering wheel, if available. It must be properly located and orientated at the proper position. The GameObject will be rotated around its local Z axis according to current steering angle. The maximum angle for the steering wheel is configured at the property steeringWheelMax. #### Ignored colliders This parameter is necessary when the vehicle's rigidbody is configured to use interpolation (_RigidBody > Interpolate_). In that case, add here any collider of the vehicle that overlaps or is close to the WheelCollider objects. This is neccesary because the interpolation could interfere with the Raycasts used for determining the wheel's vertical position, so strange visual effects can occur if the colliders are not ignored. ## Skidmarks parameters These values are defined in terms of the __tire's skid ratio__: - __0 .. 1.0__: tire is not skidding, it's conserving all its grip. 1.0 means the slip value at which the tire performs the maximum grip. - __1.0 .. 2.0__: tire is beginning to loose its grip as consequence of the increasing slip. 2.0 means the slip value at which the tire reaches its minimum grip and is heavily skidding. - __> 2.0__: tire is heavily skidding at its minimum grip value. The slip value in m/s that has surpassed the point of minimum force is this value minus 2.0. Example: a relative skid ratio of 4.0 means the tire is skidding at the slip value of minimum grip + 2 m/s. The relative skid ratio can be seen in real time in the Telemetry values FSR and SSR for each wheel (key B at the [Live Demo][1]). The Friction line shows the slip values for maximum and minimum grip, for both forward (F) and sideways (S) curves. __forwardSkidmarksBegin__: skid ratio where the skidmark begins to appear as consequence of accelerating / braking. __forwardSkidmarksRange__: range of skid ratio where the skidmark increases its intensity progressively according to the forward slip (accelerate / brake). __sidewaysSkidmarksBegin__: skid ratio where the skidmark begins to appear as consequence of sideways slip (drifting). __sidewayskidmarksRange__: range of skid ratio where the skidmark increases its intensity progressively according to the sideways slip (drift). __skidmarksWidth__ (m): use for match the skidmarks' width with the wheel's width. __skidmarksOffset__ (m): use for properly align the skidmarks with the wheels. #### Skidmarks example: Telemetry: WheelFL RPM: 0 S: 0.50 F: 6007 FS:-1.50 SS: 0.94 FSR:-1.00 SSR: 0.27 Friction F: [1.500, 2.500] S: [3.500, 6.000] The _forwards skid ratio_ (FSR) is 1.0 when the _forward slip_ (FS) is 1.500 m/s, and is 2.0 when the slip is 2.500 m/s. The further slip values in m/s are directly added to the the ratio. For example, if the forward slip value is 7 m/s, the skid ratio results in 2.0 + (7 - 2.500) = 6.5, which means "4.5 m/s above the slip value where the skid ratio is 2.0 (2.500 m/s)". forwardSkidmarksBegin = 1.5 forwardSkidmarksRange = 5.0 Skidmarks will start appearing when the forward slip (FS, accelerate / brake) is __2 m/s__ (forwardSkidmarksBegin = 1.5 = half way between 1.500 and 2.500). The skidmarks appear at their maximum intensity at the skid ratio forwardSkidmarksBegin+forwardSkidmarksRange = 1.5 + 5.0 = 6.5. This skid ratio means 4.5 m/s above the slip value corresponding to the ratio 2.0. So the slip for the maximum intensity is 4.5 + 2.500 = __7 m/s__. ## Smoke parameters These values are also defined as __skid ratio__ (see above): __forwardSmokeBegin__: minimum skid ratio where the smoke can start appearing as consequence of forward slip (burnouts, brake lock) __forwardSmokeRange__: range of forward skid ratio where the smoke increases its intensity progressively. __sidewaysSmokeBegin__: minimum skid ratio where the smoke can start appearing as consequence of sideways slip (drifting). __sidewaysSmokeRange__: range of sideways skid ratio where the smoke increases its intensity propgressively. The smoke is also controlled by the time that the tire's slip is inside the smoke range. When the tire's skid ratio reaches the SmokeBegin value, time starts counting forward. When the skid ratio decreases below the SmokeBegin value, time counts reverse. This allows to control the smoke's intensity according to the time and frequency the wheel enters into the "smoke zone". It's like a kind of tire's temperature, but just counting the heating-cooling time instead of degrees. __smokeStartTime__: time in seconds that the tire must be in the smoke's skid range in order to begin emitting smoke. 0 means that the smoke starts as soon as the tire's reaches the SmokeBegin value. __smokePeakTime__: time in seconds the tire takes to reach the maximum smoke intensity. __smokeMaxTime__: maximum time that is counted while the tire's skid ratio is over SmokeBegin. Note that this value could be smaller than smokePeakTime, so the smoke never reaches the maximum intensity. #### Smoke example: smokeStartTime = 2 smokePeakTime = 12 smokeMaxTime = 24 Provided that the tire is performing a continuous burnout, then: - 2 seconds after starting the burnout the tire starts emitting very small traces of smoke, which begin growing progressively. - 10 seconds later (at second 12) the tire is generating smoke at maximum intensity. - The burnout continues during at least other 12 seconds (total seconds: 24 or more), maximum smoke intensity. When the burnout ends the time will count reverse: - The tire will take 12 seconds to "start cooling". During those 12 seconds, if the burnout restarts the smoke will already begin at its maximum intensity. - The next 10 seconds, the tire will be "cooling" progressively. If the burnout restarts, the smoke will begin at the corresponding intensity. - The next 2 seconds the tire won't emit smoke if the burnout restarts, just the time will count forward. ## Other settings __wheelGroundedBias__: distance in meters the wheels are placed intersecting the ground. This simulates the deformation as consequence of the vehicle's weight. __steeringWheelMax__: maximum rotation degrees the steering wheel can rotate in each direction. Used for moving the steering wheel according to the user's input. [1]: http://www.edy.es/dev/vehicle-physics/live-demo }}}