Unity3d 使用四元数时阻止z轴。角度轴
我正在创建一个360浏览器,我想在陀螺仪和触摸屏之间切换。我已经完成了所有的工作,但是我想改进我有点卡住的触摸控制。我正在使用以下代码:Unity3d 使用四元数时阻止z轴。角度轴,unity3d,rotation,touch,quaternions,360-panorama,Unity3d,Rotation,Touch,Quaternions,360 Panorama,我正在创建一个360浏览器,我想在陀螺仪和触摸屏之间切换。我已经完成了所有的工作,但是我想改进我有点卡住的触摸控制。我正在使用以下代码: float x = Input.GetTouch(0).deltaPosition.x; float y = Input.GetTouch(0).deltaPosition.y; float speed2 = 0.09f; this
float x = Input.GetTouch(0).deltaPosition.x;
float y = Input.GetTouch(0).deltaPosition.y;
float speed2 = 0.09f;
this.transform.localRotation *= Quaternion.AngleAxis(x*speed2, Vector3.up);
this.transform.localRotation *= Quaternion.AngleAxis(y*speed2, Vector3.left);
它工作得很完美,但我想阻止z轴,以防止在移动手指做对角线或尝试旋转180º时出现奇怪的视图。我试过一些密码,但没有成功
非常感谢