Gear VR触摸板移动相机的问题

时间:2017-07-18 20:33:42

标签: c# unity3d virtual-reality gear-vr touchpad

我无法让我的Gear VR触控板工作 - 我只是试图在触摸时移动相机位置。我已尝试过以下两段代码:

public Camera cam;
void Update()
{
    if (Input.GetMouseButton (0)) 
    {
        cam.transform.position = new Vector3(-100f, -100f, -100f);
    }
}

void Start () 
{
    OVRTouchpad.Create();
    OVRTouchpad.TouchHandler += HandleTouchHandler;         
}

void HandleTouchHandler (object sender, System.EventArgs e)
{
    OVRTouchpad.TouchArgs touchArgs = (OVRTouchpad.TouchArgs)e;
    if(touchArgs.TouchType == OVRTouchpad.TouchEvent.SingleTap)
    {
        cam.transform.position = new Vector3(-100f, -100f, -100f);
    }
}

我的脚本已附加到OVRPlayerController

1 个答案:

答案 0 :(得分:0)

您无法移动VR相机,它是确定相机位置的SDK。

要移动相机,您只需将GameObject作为Cam的父级,然后移动父GameObject(此处ParentCamera):

public GameObject ParentCamera;

void Update()
{
    if (Input.GetMouseButton (0)) 
    {
        cam.transform.position = new Vector3(-100f, -100f, -100f);
    }
}