NWH Wheel Controller 3D
Search Results for

    Show / Hide Table of Contents

    Friction Preset

    FrictionPreset is a ScriptableObject containing data about the friction properties of a tire.

    Friction Preset Inspector

    WheelController's friction is slip-based. Tire always has some slip but it is very small under normal conditions – always near the left side of the curve below.

    Friction curve diagram

    Image above shows friction curve with slip on the X axis and friction on the Y axis. Part of the curve on the left side marked as "has traction" is where tires normally operate, and part on the right side is where the tire lost traction. Depending on the shape of the curve vehicle will act differently upon losing traction.


    Pacejka BCDE Parameters

    The friction curve is defined using the Pacejka "Magic Formula" with four parameters:

    • B (stiffness) – With higher value curve will be faster to reach peak value meaning it will be steeper. This means that wheel will require less slip to lose traction and such vehicle will be more unstable – i.e. spin out more easily. With lower values of stiffness vehicle will be more stable and harder to spin but with very low value it will start to act as if on ice.

    Stiffness parameter effect on friction curve

    • C (shape) – While stiffness determines where the peak will be, shape determines how strong the knee in the curve will be. High shape value will make it pointy while low value will make it flatter.
    • D (peak) – The higher it is the more traction wheel will have. It does exactly the same thing as Slip Coefficient field does. To simplify, resultant friction is equal to peak value times slip coefficient times some other values - this means that if peak is set to 0.5 and slip coefficient to 2 result will be exactly the same as if both were set to 1 since 0.52=11.
    • E (falloff) - Determines how fast curve will fall off after the peak. It depends on other parameters but in general lower value will mean that curve ends closer to 0, and value of 1 will mean that it is almost horizontal after the peak. If set to low value vehicle will start to slide once traction is lost and if set to high value there will be almost no difference between "has traction" and "lost traction" parts of the curve.

    Typical Preset Values

    Surface Type B C D E Notes
    Dry Asphalt 10 1.6 1.0 0.98 Balanced grip, default preset
    Race Slick 15 1.8 1.3 0.95 High grip, very sharp response
    Sport Tire 12 1.7 1.1 0.97 Between street and race
    Wet Road 8 1.5 0.75 1.0 Reduced grip, softer response
    Gravel 7 1.4 0.7 1.0 Moderate grip, gradual falloff
    Mud 6 1.3 0.5 1.0 Low grip, very soft
    Ice 5 1.3 0.2 1.0 Very low grip, very soft response

    Creating Friction Presets

    To create a new FrictionPreset:

    1. Right-click in the Project window
    2. Select Create > NWH > WheelController > Friction Preset
    3. Name the preset appropriately (e.g., "WetAsphalt", "GravelRoad")
    4. Adjust the BCDE parameters to match your desired surface characteristics
    5. Assign the preset to WheelController > Active Friction Preset

    The preset will automatically generate a preview curve based on your parameters.

    Switching Presets at Runtime

    Friction presets can be changed during gameplay to simulate surface transitions:

    WheelController wheel = GetComponent<WheelController>();
    
    // Switch to a different surface
    wheel.activeFrictionPreset = gravelPreset;
    
    // Or for all wheels on a vehicle
    foreach (WheelController wc in vehicleWheels)
    {
        wc.activeFrictionPreset = icePreset;
    }
    

    StandardFriction Component

    In v14, friction calculation is handled by the StandardFriction component, which is automatically added alongside WheelController. This component provides additional tuning parameters beyond the basic FrictionPreset.

    Grip and Stiffness

    • Grip (Vector2) - Force multiplier applied to friction output.

      • X = Longitudinal (acceleration/braking direction). Default 1.0.
      • Y = Lateral (cornering direction). Default 0.95.
      • Values above 1.0 increase grip, below 1.0 reduce it.
      • Use to fine-tune front/rear grip balance without creating separate presets.
    • Stiffness (Vector2) - Slip sensitivity multiplier.

      • X = Longitudinal. Default 1.0.
      • Y = Lateral. Default 0.8.
      • Higher values make the tire respond more aggressively to slip.
      • Lower values create a more forgiving, progressive grip limit.
    • Load Sensitivity (Vector2) - How friction scales with vertical load.

      • X = Longitudinal. Default 0.85.
      • Y = Lateral. Default 0.8.
      • Value of 1.0 = linear scaling (unrealistic).
      • Values < 1.0 = diminishing returns at high loads (realistic tire behavior).
      • At high loads, tires become relatively less effective per Newton of load.
    StandardFriction friction = wheel.GetComponent<StandardFriction>();
    
    // Increase rear grip for understeer
    friction.grip = new Vector2(1.0f, 1.1f);
    
    // Make front tires more progressive
    friction.stiffness = new Vector2(0.9f, 0.7f);
    

    Static Friction System

    The static friction system prevents low-speed jitter and enables stable vehicle parking. When wheel velocity drops below a threshold, the system switches from slip-based dynamic friction to a spring-damper anchoring system.

    Static Friction Parameters

    • Static Friction Strength - Master switch (0-1). Set to 0 to disable static friction entirely. Default 1.0.
    • Static Friction Damping - Damping ratio for the anchor spring. Default 1.0 (critical damping = no overshoot).
    • Static Friction Speed Threshold - Wheel velocity [m/s] below which static mode engages. Default 0.3 m/s.
    • Static Friction Hysteresis - Multiplier for exit threshold to prevent oscillation. Default 1.2x. The wheel must exceed (threshold × hysteresis) to exit static mode.
    • Static Break Threshold - Force multiplier required to break out of static friction. Default 1.5. If applied force exceeds (max grip × breakThreshold), static mode is broken.
    • Static Friction Cooldown Frames - Physics frames to wait before static can re-engage. Default 10. Prevents rapid oscillation between static and dynamic modes.

    Static Friction Stiffness

    • Static Longitudinal Stiffness - Spring stiffness for braking direction. Default 800. Higher values make the wheel "stick" more firmly when stopped.
    • Static Lateral Stiffness - Multiplier of longitudinal stiffness for sideways direction. Default 1.0. Set lower to allow slight sideways drift on slopes while maintaining longitudinal hold.

    Slope Handling

    The static friction system includes automatic slope compensation. When parked on an incline, the system calculates the force needed to prevent rolling and applies it through the anchor spring. This allows vehicles to park on hills without drifting.

    Breaking Static Friction

    Static friction is automatically broken when:

    • Applied force exceeds the break threshold
    • Motor torque or brake torque is applied that overcomes static hold
    • Wheel velocity increases above the exit threshold

    You can also force-break static friction via code:

    StandardFriction friction = wheel.GetComponent<StandardFriction>();
    friction.BreakStaticFriction(10); // Break with 10-frame cooldown
    

    Advanced Friction Tuning

    Low-Speed Behavior

    Additional parameters for smooth low-speed friction transitions:

    • Low Speed Surface Threshold - Speed [m/s] below which surface lock engages. Default 1.5 m/s.
    • Low Speed Force Ramp End - Speed [m/s] at which full friction force is applied. Default 1.0 m/s.
    • Low Speed Force Min Scale - Minimum force scale at very low speeds. Default 0.3. This prevents jerky starts by gradually ramping up friction.

    Solver Configuration

    For advanced users tuning the Newton-Raphson friction solver:

    • Solver Convergence Threshold - Error threshold for solver convergence. Default 0.01.
    • Max Solver Iterations - Maximum Newton-Raphson iterations (1-5). Default 3.
    • Slip Denominator Floor - Minimum slip denominator [m/s]. Default 0.5. Prevents division issues at very low speeds.

    Force Feedback

    The StandardFriction component calculates force feedback data:

    • Pneumatic Trail Coefficient - Pneumatic trail as fraction of wheel radius. Default 0.08. Affects the self-aligning torque calculation used for steering feel.

    Troubleshooting Friction Issues

    Vehicle Spins Out Too Easily

    • Lower the B (stiffness) parameter in your FrictionPreset (try 6-8 instead of 10)
    • Increase lateral load sensitivity to reduce rear grip at high loads
    • Check that center of mass isn't too far forward

    Vehicle Feels Like It's on Ice

    • Increase the D (peak) parameter for more overall grip
    • Check that you have the correct preset assigned
    • Verify StandardFriction.grip values aren't set too low

    Vehicle Jitters When Stopped

    • Ensure static friction is enabled (staticFrictionStrength > 0)
    • Increase staticFrictionDamping if oscillation occurs
    • Check that suspension damping isn't too low

    Wheels Lock Up Too Easily

    • Increase the stiffness.x value in StandardFriction
    • Consider enabling per-wheel ABS in WheelController
    • Check that load sensitivity isn't too high
    • Edit this page
    In this article
    Back to top Copyright © NWH - Vehicle Physics, Aerodynamics, Dynamic Water Physics