Wheel Colliders on custom car model disproportionately offset wheels

Hello, I have an issue regarding applying wheel colliders to my car model. While the positioning of the wheel colliders alone doesn’t cause this, whenever I run my UpdateWheels function, this causes the wheels to fly out to the sides upon running the project like so:


For reference, here is my UpdateWheels function:

[SerializeField] private WheelCollider frontLeftWheelCollider;
[SerializeField] private WheelCollider frontRightWheelCollider;
[SerializeField] private WheelCollider rearLeftWheelCollider;
[SerializeField] private WheelCollider rearRightWheelCollider;

[SerializeField] private Transform frontLeftWheelTransform;
[SerializeField] private Transform frontRightWheeTransform;
[SerializeField] private Transform rearLeftWheelTransform;
[SerializeField] private Transform rearRightWheelTransform;

private void FixedUpdate()
{
    GetInput();
    HandleMotor();
    HandleSteering();
    UpdateWheels();
}

private void UpdateWheels()
{
    UpdateSingleWheel(frontLeftWheelCollider, frontLeftWheelTransform);
    UpdateSingleWheel(frontRightWheelCollider, frontRightWheeTransform);
    UpdateSingleWheel(rearRightWheelCollider, rearRightWheelTransform);
    UpdateSingleWheel(rearLeftWheelCollider, rearLeftWheelTransform);
}

private void UpdateSingleWheel(WheelCollider wheelCollider, Transform wheelTransform)
{
    Vector3 pos;
    Quaternion rot;
    wheelCollider.GetWorldPose(out pos, out rot);
    wheelTransform.rotation = rot;
    wheelTransform.position = pos;
}

Any idea how I would fix this?

Check your wheel pivots and keep these settings in mind when editing, to avoid confusion about “what is the actual center”:

Check your pivot/center and global/local buttons in the Scene window in the editor.

Shortcut keys are Z and X to toggle those.

It may also be helpful to press PAUSE and study your scene, study positions of those objects.

Hey Kurt, thanks for the prompt response.

I tried to reposition the wheel colliders at the origin point of the rigidbody which puts the wheels in the right place. However, when I move the car forward, the same behaviour occurs:

Regardless of the center/pivot and global/local settings or the position of the wheel colliders, the same behaviour occurs where the wheels rotate wildly around the car. Strangely, the centre of this rotation is treated as relative to the wheel on the original car. Where does this issue come from and how would I resolve it?

You can fix it easily like this. For each wheel:

  1. Create a new GameObject as child of the car root.
  2. Ensure the rotations of the new GameObject are 0, 0, 0. “Forward” must be pointing in the “front” direction of the car.
  3. Move the new GameObject to the precise position of the wheel center.
  4. In the Hierarchy, drag & drop the current transform of the visual wheel to make it child of the new GameObject.
  5. Apply the position and rotation to the transform of this new GameObject instead of the original visual wheel transform.

Now the wheels will rotate as expected.