Search Unity

Resolved Wheel Damping in curve wrong

Discussion in 'Physics' started by ShinjixMRT, May 6, 2023.

  1. ShinjixMRT

    ShinjixMRT

    Joined:
    May 26, 2019
    Posts:
    2
    Hey commu,

    i´ve got a problem with my wheel collider and its dampers.
    If i drive in a curve, its damping in the wrong side.
    How can i explain ist... You drive a light left curve and normally due to gravity and centrifugal forces the dampers should be on the left higher than on the right. But its not obviously.

    Has anybody an explanation or is it maybe a part of the code?

    All coliders have the same setting.

    damper.png


    Code (CSharp):
    1.  private void HandleSteering()
    2.     {
    3.         if (HorizontalIn == 0)
    4.         {
    5.             if (currentSteerAngle > 0)
    6.                 currentSteerAngle -= SteeringSpeed;
    7.             if (currentSteerAngle < 0)
    8.                 currentSteerAngle += SteeringSpeed;
    9.         }
    10.  
    11.         if (HorizontalIn > 0)
    12.             currentSteerAngle += SteeringSpeed;
    13.         if (HorizontalIn < 0)
    14.             currentSteerAngle -= SteeringSpeed;
    15.  
    16.         if (currentSteerAngle < -maxSteerAngle)
    17.             currentSteerAngle = -maxSteerAngle;
    18.         if (currentSteerAngle > maxSteerAngle)
    19.             currentSteerAngle = maxSteerAngle;
    20.  
    21.  
    22.  
    23.         fLCollider.steerAngle = currentSteerAngle;
    24.         fRCollider.steerAngle = currentSteerAngle;
    25.     }
    26.     private void UpdateWheels()
    27.     {
    28.         UpdateSingleWheel(fLCollider, fLTransform);
    29.         UpdateSingleWheel(fRCollider, fRTransform);
    30.         UpdateSingleWheel(rLCollider, rLTransform);
    31.         UpdateSingleWheel(rRCollider, rRTransform);
    32.     }
    33.     private void UpdateSingleWheel(WheelCollider wheelCollider, Transform wheelTransform)
    34.     {
    35.         Vector3 pos;
    36.         Quaternion rot;
    37.         wheelCollider.GetWorldPose(out pos, out rot);
    38.         wheelTransform.rotation = rot;
    39.         wheelTransform.position = pos;
    40.  
    41.     }
     
  2. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    2,508
    Most likely the center of mass of the rigidbody is located below the ground.
     
    ShinjixMRT likes this.
  3. ShinjixMRT

    ShinjixMRT

    Joined:
    May 26, 2019
    Posts:
    2
    Thank you, thats it :D
     
    Edy likes this.