I have coded up a simple raycast script that is attached to the hand of an Oculus Motion Controller. The idea is - the controller acts like a vacuum, it sucks up the prefabbed objects called "Eosinophil2(Clone)".
On a few tests outside of the motion controller this works.
The trouble I am experiencing is when I place the Raycast script into the motion controller. It only appear to work as anticipated when I am beside the Guardian Border.
I have turned on and off the border to see if that solved anything but it did not.
I've checked that the line raycast line goes in the right direction - and it is.
Any ideas?
void FixedUpdate()
{
// OVRInput.SetControllerVibration(.3f, 0.3f, OVRInput.Controller.RTouch);
var up = transform.TransformDirection(Vector3.forward);
//note the use of var as the type. This is because in c# you
// can have lamda functions which open up the use of untyped variables
//these variables can only live INSIDE a function.
RaycastHit hit;
Debug.DrawRay(transform.position, up * 20, Color.green,1);
if (Physics.Raycast(transform.position, up, out hit, 20))
{
if (hit.collider.gameObject.name == "Eosinophil2(Clone)")
{
OVRInput.SetControllerVibration(.3f, 0.3f, OVRInput.Controller.RTouch);
hit.collider.gameObject.transform.position = Vector3.MoveTowards(hit.collider.gameObject.transform.position, transform.position, 20 * Time.deltaTime);
}
else
{
//OVRInput.SetControllerVibration(0, 0, OVRInput.Controller.RTouch);
}
}
}
private void OnTriggerEnter(Collider other)
{
if (other.gameObject.transform.name == "Eosinophil2(Clone)")
{
this.gameObject.GetComponent<AudioSource>().Play(0);
Debug.Log("works");
Destroy(other.gameObject);
Debug.Log("HIT ONE!");
hitRate++;
}
}`enter code here`
Moral of the story - build your scene from scratch.
Use the OVRCameraRig prefab in said build scene.
Using prebuilt scenes from Oculus can be detrimental to ones health, time and code.
I hope this helps someone someday.