我有我的带有轮式对撞机的模型设置,它驱动良好。一切运行良好,包括模拟悬挂的轮网位置。我唯一的问题是,当我运行游戏时,我的轮子在 Y 轴上旋转了 90 度,然后侧向滚动。如何在脚本中旋转网格以使其正确显示?我主要只需要位置,但使用 wheel.getworldpose 迫使我使用四元数和 Vector3。我可以在不使用四元数的情况下做到这一点吗?
这是一个图像...
// 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;
}