AngularVelocity 相对于 CameraRig (VR)

AngularVelocity relative to a CameraRig (VR)

我有点困惑。我正在尝试让我在 VR 中从手中释放的对象采用控制器的正确速度和角速度,以便它们的释放运动感觉自然。这是跟踪控制器角速度和速度并在释放时将其传递给对象的简单问题:

 rigid.velocity = controller.currentVelocity;
 rigid.angularVelocity = controller.currentAngularVelocity;

然而,问题来了,我还有一个运动系统,它恰好相对于玩家的头部旋转 CameraRig,在这样做之后,这些值都是错误的,并且相对于 cameraRig 移动了所以:

 cameraRig.transform.RotateAround(headsetCamera.transform.position, Vector3.up, -(headsetCamera.transform.eulerAngles.y - lastHeadRot.y));
 lastHeadRot = headsetCamera.transform.eulerAngles;

我曾尝试寻找类似这样的答案 (ref) and this (ref),但 none 确实奏效了。欢迎提出任何建议。当使用其他形式的运动时,角速度和速度会正确设置为抛出的物体,但一旦我在 cameraRig 上使用 rotateAround 就不会了。

我终于解决了这个问题,所以我想我会在这里添加解决方案。

而不是使用此代码来抛出对象:

 _rigid.velocity = controller.currentVelocity;
 _rigid.angularVelocity = controller.currentAngularVelocity;

我用过:

 _rigid.AddForce(controller.currentVelocity);
 _rigid.angularVelocity = controller.currentAngularVelocity;

这解决了问题,现在无论父对象的旋转如何,对象都会朝着预期的方向飞行。