Gear VR movement not working properly.

I’m having some issues with moving around my scenes with Gear VR. I have quite a simple setup where the player taps the touchpad and the camera will move to the location that the player was looking at when they tapped the pad.

It works okay in the editor when I tap the mouse button to simulate the touchpad. However, in Gear VR it moves in a completely different direction to the one requested.

The touchpad is initialised like this:

	void Start () {
        OVRTouchpad.TouchHandler += OVRTouchpad_TouchHandler;

        Random.seed = level;
        NewLevel();

	}

Input is then handled with a handler:

    private void OVRTouchpad_TouchHandler(object sender, System.EventArgs e)
    {
        OVRTouchpad.TouchArgs touchArgs = (OVRTouchpad.TouchArgs)e;
        OVRTouchpad.TouchEvent touchEvent = touchArgs.TouchType;

        switch (touchEvent)
        {
            case OVRTouchpad.TouchEvent.SingleTap:
                // Move and select things - but only if not already moving
                if (!isMoving)
                {
                    Vector3 hitPos = HitSquare();
                    if (!IsWater(hitPos))
                    {
                        // Just move for now
                        MoveTo(hitPos);
                    }
                }
                break;
            case OVRTouchpad.TouchEvent.Right:
                // Create ground
                // Can't create ground if moving
                if (!isMoving)
                {
                    // Work out if it's light green or dark green
                    Vector3 hitPos = HitSquare();
                    Vector2 pos2D = _3DToMap(hitPos.x, hitPos.z);

                    if (IsWater(hitPos))
                    {
                        // Place sand at this position
                        Color sand = new Color(1.0f, 0.921f, 0f);
                        map.SetPixel((int)pos2D.x, (int)pos2D.y, sand);
                        map.Apply();
                    }
                    else
                    {

                        if (pos2D.x % 2 == 0) // Is even numbered column?
                        {
                            if (pos2D.y % 2 == 0)
                            {
                                // Is even numbered row, so dark green squares
                                map.SetPixel((int)pos2D.x, (int)pos2D.y, Color.green);
                                map.Apply();
                            }
                            else
                            {
                                // Odd numbered row, so light green squares
                                map.SetPixel((int)pos2D.x, (int)pos2D.y, new Color(0.194f, 0.905f, 0.194f));
                                map.Apply();
                            }
                        }
                        else
                        {
                            // Odd numbered column
                            if (pos2D.y % 2 == 0)
                            {
                                // Is even numbered row, so light green squares
                                map.SetPixel((int)pos2D.x, (int)pos2D.y, new Color(0.194f, 0.905f, 0.194f));
                                map.Apply();
                            }
                            else
                            {
                                // Odd numbered row, so dark green squares
                                map.SetPixel((int)pos2D.x, (int)pos2D.y, Color.green);
                                map.Apply();
                            }
                        }
                    }
                }
                break;
        }
    }

The player looks at an area on the floor and taps the touchpad. The following code does a raycast to get the type of floor tile at the point looked at and stores the destination location. The camera then moves during the update.

    Vector3 HitSquare()
    {
        Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
        RaycastHit hit;

        Physics.Raycast(ray, out hit);

        return hit.point;
    }

    void MoveTo(Vector3 worldPosition)
    {
        isMoving = true;
        moveDestination = worldPosition;
        GameObject camContainer = GameObject.Find("CameraContainer");
        moveDestination.y = camContainer.transform.position.y;
    }
    


void Update () {
	
        if (isMoving)
        {
            GameObject camContainer = GameObject.Find("CameraContainer");
            float step = Time.deltaTime * moveSpeed;
            camContainer.transform.position = Vector3.MoveTowards(Camera.main.transform.position,
                moveDestination, step);

            if (camContainer.transform.position == moveDestination)
                isMoving = false;
        }
	}

Like I said, it works fine in the editor but the camera moves off to a completely different direction in Gear VR.

I’m assuming you’re using the OVRPlayerController, have you attached your script to the CenterEyeAnchor? If not you can’t guarantee you’ll teleport to the correct spot. The other possibility I can think of is that you may have inadvertently rotated one of the nested components in the controller meaning your camera is not facing the direction you think it is. I’m not an expert with this but have just implemented a similar system and those were the issues I hit on.