private void ComputeSpeed() {
// Main speed in km/h.
speed = rigidBody.velocity.magnitude * 3.6f;
// wheel circumference in meter. (radius in meter)
float circumferenceLeft = 2 * Mathf.PI * wheelLeftCollider.radius;
float circumferenceRight = 2 * Mathf.PI * wheelRightCollider.radius;
// Speed in meter per minute. (from radius in meter and revolutions per minute)
speedLeft = wheelLeftCollider.rpm * circumferenceLeft;
speedRight = wheelRightCollider.rpm * circumferenceRight;
// Convert meter per minute to kilometers per hour (km/h) (* 60 minutes / 1000 meter)
speedLeft *= 60f / 1000f;
speedRight *= 60f / 1000f;
textSpeed.text = "Speed: " + speed + "; speed L/R: " + speedLeft + " / " + speedRight;
}

A source code is worth a thousand words.
Itâ€™s the script / method of a trailer attached via joint on a vehicle. It drives 5 km/h.
The computed speed from velocity of the trailer is correct. But the wheels are 1 km/h faster if the rigidbody velocity magnitude is 5 km/h. (about 20**%** faster, more pr. 17.1%). It does not matter if I change the wheel radius. But whatâ€™s wrong?

The wheel collider has default settings. (radius 0.57m, 20 mass, etc.) And the trailer is passive. It does not apply force (motorTorque). There is no slip. If so, they should be slower. Because the wheels are passive.

I would be very grateful for every tip and advice.

my first guess was the wheel radius giving another number because itâ€™s spining, but youâ€™re not taking rotation into account so no(you also said you tried checking this)

maybe itâ€™s calculating the speed the wheel will move if you have no loss from drag and friction?
seems unlikely but what else can it be?

Thanks. But the trailer is passive. It does not have a motor. RPM is the rotation. If there is a loss of drag and friction, the speed of the wheels should be slower, I think. I measured the real speed by distance and time messure. The rigidbodys are correct. Only the wheels are about 17.2% faster. I compute the wheel circumference by 2 * PI * radius and multiplicate by revolutions per minute. So the radius change does not affact the speed on a dragged trailer.

My current workaround is compute the final value with factor successively approximated. (the 17.2%)

speedLeft /= 1.172f;
speedRight /= 1.172f;

I would be interested to know why that happen.
Mabye my calculations or parameters are wrong.
I have to validate the rpm first. â€¦ Whatever, for now it works with my factor value.

The conversions look right. The only thing that I see right off hand, and with modern compilers it shouldnâ€™t be an issue, but in your calculation of the circumference you multiply by 2 which will by default be interpreted as a int type. Try multiplying by 2f and forcing the value to be interpreted as a float. I have had issues in the past (admittedly with much older systems) that would look at your calculation of the circumference and return a integer value instead of a floating point value. Like I said, itâ€™s unlikely, but it would be a good change to make regardless.

Thanks, I also had issues like these (float * int calculations) in the past. Anyway. I updated Unity and now this â€śbugâ€ť is gone. I donâ€™t know what happend. But I removed the workaround (divide with a factor). It also works with â€ś2â€ť (int) and â€ś2fâ€ť (float). Thatâ€™s really weird. I have to check the bug fixes. I really changed nothing. I love bugs like these. -.- Iâ€™ll never know the cause. Whatever â€¦

Update: Iâ€™ve found the problem. The gameobject with the rigidbody component is scaled.
I compute the circumference by the radius of the wheel collider. But this value does ignore the scale.

scaling rigidbodys and anything physics is a big no-no afaik.

i tend to solve the scale either at the modeling software or on the import setting, i only budge the gameobject scale if i need it to scale on runtime.