flWheel.Rotate(leftWheel.rpm / 60 * 360 * Time.deltaTime, 0,0);
I am using the aboce script, in order to make the wheel rotate. However, what happens, if that the wheel is not rotating around its axis. the wheel rotates and takes a circular direction around the car,instead on its own.
void Rotate(Vector3 axis, float angle, Space relativeTo);
Either “axis” is wrong, or you should use “Space.Self” for “relativeTo”. That’s all i can tell from what little info you gave.
The wheel pivot isn’t in the flWheel center! In the Scene view, click the moving tool and the wheel: the axes gizmo will appear in the point the wheel is rotating around, not in the wheel’s center. This can happen if the wheel model was created not centered in the 0,0,0 position in some modeling softwares - return to this program and fix the pivot position. Another cause can be in Unity: if flWheel is an object which contains the wheel model, the model may be out of center.
If the wheel is rotating around the car then either the object's center is not where it should be, or it uses the parent's center.
In the first case the only way i know of is to edit the object to change it’s center in a program like 3DSMax, or Blender.
In the second case, use Space.Self as the third parameter in your rotate. By default it’s Space.Self, but it may have a bug if it uses the parent object’s center.
Edit : i just remembered there's a RotateAround method. It allows you to specify a
pivot point. You should be able to, in worst case, add an empty GameObject, to use it as the pivot.