如何让我的车轮网格在正确的轴上旋转?

How do I get my wheel mesh to rotate on the proper axis?

我的模型设置了车轮碰撞器,它运行良好。一切都运行良好,包括用于模拟悬架的车轮网格的位置。我唯一的问题是,当我 运行 游戏时,我的轮子在 Y 轴上旋转 90 度,然后横向滚动。如何在脚本中旋转网格以使其正确显示?我主要只需要位置,但使用 wheel.getworldpose 迫使我使用四元数和 Vector3。我可以在不使用四元数的情况下做到这一点吗?

这是一张图片...

d 旋转...

 // Visual updates
    void Update()
    {
        if (!driveable)
        {
            return;
        }

        // SETUP WHEEL MESHES

        // Turn the mesh wheels
        frontLeftWheelWrapper.localEulerAngles = new Vector3(0, 0, steerAngle);
        frontRightWheelWrapper.localEulerAngles = new Vector3(0, 0, steerAngle);

        // Wheel rotation
        frontLeftWheelMesh.Rotate(0, 0, wheelFL.rpm / 60 * 360 * Time.deltaTime);
        frontRightWheelMesh.Rotate(0, 0, wheelFR.rpm / 60 * 360 * Time.deltaTime);
        rearLeftWheelMesh.Rotate(0, 0, wheelRL.rpm / 60 * 360 * Time.deltaTime);
        rearRightWheelMesh.Rotate(0, 0, wheelRR.rpm / 60 * 360 * Time.deltaTime);

        //Wheel Position
        foreach (WheelCollider wheel in m_Wheels)
        {

            Quaternion q;
            Vector3 p;
            wheel.GetWorldPose(out p, out q);

            // Assume that the only child of the wheelcollider is the wheel shape.
            Transform shapeTransform = wheel.transform.GetChild(0);
            shapeTransform.position = p;
            shapeTransform.rotation = q;
        }

我终于通过注释 shapetransform.rotation = q;

解决了这个问题

然后我在我的脚本中使用原来的旋转来旋转轮子,我使用wheel.getworldpose来更新位置。