Wheel Controller

Field Explanations

Wheel
Wheel section of WheelController inspector.
  • Vehicle Side is auto-detected and it determines which side of the vehicle is on. If it is a motorcycle use Center.
  • Radius and Width need to be adjusted manually to fit the wheel model. Turn on gizmos to be able to see wheel gizmo.
  • Rim Offset is equal to the distance between the suspension center and the rim center.
Rim Offset. Frontal wheel view.
  • Drag Torque is brake torque that is constantly applied to imitate rolling resistance.
  • Parent is a parent object to which the forces will be applied. Must have a Rigidbody attached.
  • If Use Rim Collider is true a half-circle mesh collider is generated and placed on the top half of the wheel to prevent that section of the wheel detecting objects as ground which can cause the wheel to jump suddenly. Also prevents side of the wheel from going through objects as the ground detection only happens on the bottom half of the tire thread.
RimCollider example.
Wheel Visual
Wheel Visualsection of WheelController inspector.
  • Visual is a model representing the wheel. It needs to have Unity-correct rotation and centered pivot. If the rotation or pivot on the model is wrong it should be fixed either in 3D software (e.g. Blender) or by following the steps in this link. The method from the link can be applied both for rotation and pivot.
  • Since WheelController version 4.x (included with NWH Vehicle Physics 2) rotation and pivot can also be adjusted through Visual Position Offset and Visual Rotation Offset. Visual Rotation Offset's Z-axis can also be used to introduce wheel wobble if the wheel is damaged.
Wheel visual with Unity-correct rotation and centered pivot.
Spring
Spring section of WheelController inspector.
  • Max Force is the maximum force the spring will be able to exert when fully compressed.
  • Max Length is the maximum extended spring length. Unlike in Unity's WheelCollider there is no target spring position setting as the spring will fully extend (as it should) when in the air. Therefore, the resting length of the spring is not known beforehand. Because of that the best way to position the vehicle to be in its resting position is to enter play mode, let the vehicle settle and then copy over the Transform values.
  • Force Curve is an AnimationCurve with normalized values on both axes (both 0 to 1). X represents spring compression (0 for relaxed, 1 for compressed) and Y axis represents force. Actual X and Y maximum values are adjusted through Max Force and Max Length.
Damper
Damper section of WheelController inspector.
  • Bump Force - maximum damper force when damper is getting compressed.
  • Rebound Force - maximum damper force when damper is getting extended.
  • Curve - damper curve that determines relationship between spring velocity (X-axis, normalized) and force (Y-axis, normalized).
Geometry
Geometry section of WheelController inspector.
  • Camber At Top and Camber At Bottom indicate camber at top and bottom of suspension travel.
Negative, neutral and positive camber.
  • Squat - as tire applies force to the ground through friction a torque in the opposite direction gets generated around wheel axle. Squat field determines percentage of that torque which gets transferred to the vehicle. 1 (100%) will result in rear end squatting on acceleration while -1 (-100%) will do exactly the opposite. In real world this depends on the suspension setup.
Friction
Friction section of WheelController inspector.
  • Active Friction Preset - currently active friction preset / curve. Check Friction Preset page for more info.
  • Slip Coefficient - coefficient by which the slip will be multiplied. Can be used to modify friction behavior without modifying currently active curve.
  • Force Coefficient - coefficient by which the tire friction force will be multiplied. Roughly equal to D parameter of Friction Curve's Pacejka Parameters.
Load and Forces

Tire's grip increases with load placed on it. How much depends on the tire but in most tires this grip/load relation is linear until certain point when it starts to level off. Load Grip Curve imitates that relation where X-axis represents percentage (0 to 1) of Maximum Tire Load and Y-axis represents percentage (0 to 1) of Maximum Tire Grip Force. Wheel behavior heavily depends on these values.

Depenetration

When the suspension bottoms out a piece of code run that prevents the wheel from going through the ground. This behaves as a very stiff spring and damper, effectively emulating the rubber bump stops on a real vehicle.

  • Depenetration Spring - The amount of force applied (coefficient) in proportion to the penetration depth. Behaves similar to the normal suspension spring.
  • Depenetration Damper - The amount of force applied (coefficient) in proportion to the wheel velocity. Reduces the amount of bounce-back on impact. Similar to the regular suspension damper.
Ground Detection
Ground Detection section of WheelController inspector.

Ground detection in WheelController happens by firing one or multiple Raycasts and working out from those the shape of the terrain. This is heavily optimized and raycasts are batched. Still, number of rays does affect performance as there is some post-processing of received hit data required.

  • Multiple rays can be used when better ground detection resolution is required, such as in off-road games. Longitudinal Scan Resolution and Lateral Scan Resolution determine the resolution of the grid of rays that will be cast.
  • Apply Force To Others - if true wheel will interact with other Rigidbodies.
Ground Detection - Layer Mask

Since Raycast is used to detect ground the wheel will also detect other objects, such as the vehicle itself. To prevent this a Layer Mask is used. By default Auto Setup Layer Mask is ticked and all the layers assigned to the Parents (Vehicle's) colliders will be automatically removed from the Layer Mask (i.e. will be ignored).

  • If setting up the Layer Mask manually it is important to also un-tick IgnoreRaycast layer.
  • Do not use Default as body collider layer.
Debug Values
Debug section of WheelController inspector.

Debug sections shows the most important values of the wheel.

  • Enable Debug to show more detailed debug gizmos.
Wheel gizmo with Debug enabled.
  • Suspension Force Magnitude value can be used to balance the vehicle's weight distribution. Adjust Rigidbody's center of mass until all wheels have the same force magnitude on the flat surface to get 50/50 weight distribution. If using WheelController asset adjusting center of mass is done through an included script, if using NWH Vehicle Physics 2 this is done through Settings tab of VehicleController.