I have a car in Unity. Scripts are C#. I have noticed that my tire meshes' rotation is faster than whellcollider rotation. I am using this code for wheel rotation

 flWheel.localEulerAngles = new Vector3(flWheel.localEulerAngles.x, flWheelCollider.steerAngle - flWheel.localEulerAngles.z, flWheel.localEulerAngles.z);
 frWheel.localEulerAngles = new Vector3(frWheel.localEulerAngles.x, frWheelCollider.steerAngle - frWheel.localEulerAngles.z, frWheel.localEulerAngles.z);

 flWheel.Rotate(flWheelCollider.rpm / 60 * 360 * Time.deltaTime, 0, 0);
 frWheel.Rotate(frWheelCollider.rpm / 60 * 360 * Time.deltaTime, 0, 0);
 rlWheel.Rotate(rlWheelCollider.rpm / 60 * 360 * Time.deltaTime, 0, 0);
 rrWheel.Rotate(rrWheelCollider.rpm / 60 * 360 * Time.deltaTime, 0, 0);

I found this from here

Does anyone know how to fix this?


Using AquaGeneral's answer I could able to solve rotation problem. But now front right tire position changed to rear left tire position and rear right tire rotated 180 on Y axis. need help

enter image description here


1 Answer 1


The code you found is not the ideal way to go about this. Instead of figuring out exactly what is causing the issue for you, just use the builtin function: WheelCollider.GetWorldPose.

From the official Unity Wheel Collider Tutorial in the ApplyLocalPositionToVisuals function/method:

// Get the child of the wheel that has the mesh renderer
Transform visualWheel = collider.transform.GetChild(0); 

Vector3 position;
Quaternion rotation;
collider.GetWorldPose(out position, out rotation);

visualWheel.transform.position = position;
visualWheel.transform.rotation = rotation;
  • \$\begingroup\$ Rotation problem solved. But tire meshes positions changed. How fix it? \$\endgroup\$ Commented Jul 2, 2016 at 7:51
  • \$\begingroup\$ @SajithaRathnayake Could you explain further about what you mean by "tire meshes positions changed"? \$\endgroup\$ Commented Jul 2, 2016 at 12:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .