2016-07-26 54 views
0

垂直recenter调用如何GVR /纸板团结

GvrViewer.Instance.Recenter();` 

只会水平recenters的观点,我需要它也垂直。

我使用的是最新的统一测试和GVR 0.8`

+0

什么是'GvrViewer'呢? – Droppy

+0

@Droppy Google Vr API中的一个类。 – Programmer

回答

2

您可以通过您的VR相机对象的另一个对象的子recenter(姑且称之为父)和的相反方向转动父你的VR相机的旋转。这个简单的脚本将做(附于母公司):

public class Recenterer:MonoBehaviour 
{ 

    public Transform VRcam; // drag the child VR cam here in the inspector 

    public void Recenter() 
    { 
     transform.localRotation = Quaternion.Inverse(VRcam.rotation); 
    } 

} 
+0

哇!非常感谢! – curtiss

0

从谷歌VR SDK 1.50(和Unity 5.6),你可以做

transform.eulerAngles = new Vector3(newRot.x, newRot.y, newRot.z); 
UnityEngine.VR.InputTracking.Recenter(); 

另外,如果你不想让你感到困惑还需要捕获GvrEditorEmulator实例和Recenter。

#if UNITY_EDITOR 
     gvrEditorEmulator.Recenter(); 
#endif 

Recentering GvrEditorEmulator但似乎并没有在目前的工作非常好,但如果你禁用它,你会看到主摄像头recentering作品。