Samsung Gear VR - Create Oculus 3d Pointer

1.2k Views Asked by At

I want to create pointer to my game

my tries

1- Create sphere object.

2- Attach this sphere to right eye (RightEyeAnchor).

3- Adapt sphere to have same space from right eye

4- Write code below .

using UnityEngine;
using System.Collections;

public class Pointer_Mock : MonoBehaviour {

 public GameObject targetCam;
 // Use this for initialization
 void Start () {
  targetCam = transform.parent.gameObject;
 }

 void Update() {
  transform.LookAt (targetCam.transform);

  float localX = transform.localPosition.x;
  float localY = transform.localPosition.y;

  float h = (localX += (Input.GetAxis("Mouse X") * 0.05f));
  float v = (localY += (Input.GetAxis("Mouse Y") * 0.05f));
  transform.localPosition = new Vector3 (h, v, transform.localPosition.z);

 }
}

5- Attach right eye code to my script // I am not sure what desired game object

This tutorial that I follow

http://unitygirldev.blogspot.com/2015/01/unity-script-oculus-3d-pointer.html

1

There are 1 best solutions below

1
On

There is a guide on the Oculus forum that might help you, in particular this section which suggests setting camera to CenterEyeAnchor rather than RightEyeAnchor:

  1. Under the OVRCameraRig->CenterEyeAnchor object, add a regular Unity Camera at position and rotation 0,0,0, and set this camera's Culling Mask to "Nothing" so it won't actually bother rendering anything and waste CPU/GPU cycles. I named it "Look Camera". This camera is just for use by the UI event system. By putting it under the CenterEyeAnchor object, it tracks perfectly with the head. The OVR cameras don't seem to work with the UI system, probably because they utilize render textures and not screen space rendering. This dummy look camera solves that problem.

You also need to set render mode to World Space. This can be found on the render mode drop down list for the UI Canvas object:

enter image description here