Search Unity

Wheel collider suspension lifts car on weight

Discussion in 'Physics' started by the_mr_matt, May 20, 2020.

  1. the_mr_matt

    the_mr_matt

    Joined:
    Jul 21, 2015
    Posts:
    124
    My wheel colliders raise the vehicle when a weight is placed on the vehicle. This is unexpected behaviour. When a weight is applied the car should lower towards the ground.

    See the video below.



    I am using easy suspension on the wheel colliders. This is my configuration:
    • Vehicle mass: 1000
    • Couch mass: 70
    • Natural Frequency: 11
    • Damping Ratio: 0.5
    • Force Shift: 0.2
    • Wheel Radius: 0.4
    • Wheel Mass: 50
     
  2. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    2,510
    Forcing a natural frequency / damping ratio in a car is not a good idea. These properties are consequences of the current car setup and load. Trying to force them involves artificially modifying the suspension spring and damper to for trying to match some specific natural frequency and damping ratio, leading to unwanted secondary effects such as the one you observe. I don't recommend to use EasySuspension nor any other approach that involves forcing some natural frequency / damping ratio when minimal realism is expected.

    Check out this document on simple suspensions:


    The formula for the natural frequency at rest is:

    naturalFrequency = sqrt(gravity / contactDepth)​

    Adding some load to the car causes an increment in the contact depth (= car lowers to the ground). As you can see in the formula incrementing the contact depth reduces the natural frequency. This is easily observable in real cars: the more loaded they are, the slower the suspension bounces.

    But when the simulation wants to preserve some naturalFrequency then it must keep the contact depth constant even when load is added. The only way to do that is making the springs stiffer, so you see your car "lifting" the load.

    The correct approach for realistic effect is not using EasySuspension, but configure the springs and dampers once and leave them untouched. Then the car responds properly with the load, as shown in this video:



    You can see how the suspension bounces slower when the car is loaded (that grey cube weights 500Kg) and faster when it's unloaded. That's what happens in reality.
     
  3. the_mr_matt

    the_mr_matt

    Joined:
    Jul 21, 2015
    Posts:
    124
    Thanks for the reply. This is interesting.

    Although, like you mentioned, currently do setup the suspension once only at start. The code below is called on start and is based on easy suspension.

    Code (CSharp):
    1.  
    2. private void SetupSuspension()
    3. {
    4.     for (int i = 0; i < m_WheelColliders.Length; i++)
    5.     {
    6.         m_WheelColliders[i].ConfigureVehicleSubsteps(5f, 30, 40);
    7.  
    8.         JointSpring spring = m_WheelColliders[i].suspensionSpring;
    9.  
    10.         spring.spring = Mathf.Pow(Mathf.Sqrt(m_WheelColliders[i].sprungMass) * m_NaturalFrequency, 2);
    11.         spring.damper = 2.0f * m_DampingRatio * Mathf.Sqrt(spring.spring * m_WheelColliders[i].sprungMass);
    12.  
    13.         m_WheelColliders[i].suspensionSpring = spring;
    14.  
    15.         Vector3 wheelRelativeBody = transform.InverseTransformPoint(m_WheelColliders[i].transform.position);
    16.         float distance = m_RigidBody.centerOfMass.y - wheelRelativeBody.y + m_WheelColliders[i].radius;
    17.  
    18.         m_WheelColliders[i].forceAppPointDistance = distance - m_ForceShift;
    19.  
    20.         if (spring.targetPosition > 0.0f)
    21.         {
    22.             m_WheelColliders[i].suspensionDistance = m_WheelColliders[i].sprungMass * Physics.gravity.magnitude / (spring.targetPosition * spring.spring);
    23.         }
    24.     }
    25. }
    Do you see any way I can work around this?
     
  4. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    2,510
    Disabling vehicle substeps may help for the suspension, but it will cause other issues in the friction. Simply call:
    Code (CSharp):
    1. m_WheelColliders[0].ConfigureVehicleSubsteps(1f, 1, 1);
    You may call this method only once for any wheel. It will affect the entire vehicle. No need to call it for each wheel.
     
  5. the_mr_matt

    the_mr_matt

    Joined:
    Jul 21, 2015
    Posts:
    124
    No luck. I tried commenting out the entire SetupSuspension() method and resetting the wheel collider back to default values. The same behaviour occurs.
     
  6. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    2,510
    The WheelCollider, ladies and gentlemen. :(
     
    the_mr_matt likes this.
  7. the_mr_matt

    the_mr_matt

    Joined:
    Jul 21, 2015
    Posts:
    124
    New discovery.

    The couch was using 13 small compound box colliders. If I replace this with one bounding box collider the weird lifting behavior stops.

    Testing this with a simplified car and box weights I have found that when more than one collider falls on the vehicle, the lifting behavior occurs; when only one collider falls on the vehicle, the behavior stops.
     
  8. the_mr_matt

    the_mr_matt

    Joined:
    Jul 21, 2015
    Posts:
    124
    Here's a video of my discovery. Both boxes have a mass of 150kg. The red box has one box collider, the green box has two smaller box colliders. Notice how when the green box is released, the car bounces back up higher than it was sitting at rest.

    I just want to emphasize the only difference between the red and green boxes is the number of colliders. This is clearly a wheel collider bug.

     
    Edy likes this.
  9. the_mr_matt

    the_mr_matt

    Joined:
    Jul 21, 2015
    Posts:
    124
    Fixed the issue by resetting physics settings.
     
  10. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    2,510
    Can you file a bug report with that simple scene with repro instructions? It would also help to use some simple cylinders to clearly show the positions of the wheels. Include a short video as well.