ivanmkc
ivanmkc

Reputation: 138

Teleporting Camera in Google Daydream won't work

I'm using the Unity technical preview with Daydream support on testing on a Pixel with the Daydream View and Controller.

I've successfully deployed my scene to my device and everything works as expected.

However, for the life of me, I can't get the camera to teleport. I point at the floor and can teleport other objects to where I point, but not the camera. In fact, when I check the transform, the camera teleports fine, but the view I see on the Pixel, doesn't update. Is there something I have to call on the GVRViewer script?

Here is the relevant code:

RaycastHit hitInfo;
            Vector3 rayDirection = GvrController.Orientation * Vector3.forward;
            if (Physics.Raycast(controllerPivot.transform.position, rayDirection, out hitInfo)) {
                if (hitInfo.collider && hitInfo.collider.gameObject) {
                    SetSelectedObject(hitInfo.collider.gameObject);

                    //Teleport on click
                    if (selectedObject == floor) {
                        if (GvrController.ClickButtonDown) {
                            selectedObject.GetComponent<Renderer>().material = cubeActiveMaterial;
                            controllerPivot.transform.position = new Vector3 (hitInfo.point.x, controllerPivot.transform.position.y, hitInfo.point.z);
                            playerCamera.transform.position = new Vector3 (hitInfo.point.x, playerCamera.transform.position.y, hitInfo.point.z);
                            gvrControllerMain.transform.position = new Vector3 (hitInfo.point.x, gvrControllerMain.transform.position.y, hitInfo.point.z);
                    }
                }
            }

Upvotes: 1

Views: 471

Answers (1)

ivanmkc
ivanmkc

Reputation: 138

After more intense Googling, these 2 links helped me out.

http://answers.unity3d.com/questions/1095115/gear-vr-moving-camera-no-input-controls-work.html

https://docs.unity3d.com/Manual/VROverview.html

Apparently, doing VR in Unity means the camera transform is overridden and the solution is to put the camera in another object and transform that.

Upvotes: 2

Related Questions