I am trying to design a game for the oculus rift that is moving an object on a plane using the mouse. I have a code that works great in unity but when I load the game into the oculus, both the camera and mouse move the object. Does anyone know if there is a way to separate the head movement from the mouse movement (maybe casting from a child of the object I am trying to move)? Thank you!
Here is the code that I have so far…
RaycastHit hit;
private float raycastLength = 1000;
void Update()
{
GameObject Mouse = GameObject.Find ("Mouse");
Ray ray = Camera.main.ScreenPointToRay (Input.mousePosition);
if (Physics.Raycast (ray, out hit, raycastLength)) {
Debug.Log (hit.collider.name);
if (hit.collider.name == "Tablet")
{
Mouse.transform.position = hit.point;
}
}
Debug.DrawRay(ray.origin, ray.direction * raycastLength, Color.yellow);
}
}