I have a Physics Raycaster attached to the Camera. The Pointer Click Event Trigger is working correctly. However I need to do it from the source code. These are my attempts:
private void SetOnPushButtonFireManager(){
cardboard.OnTrigger += () => {
Debug.Log("Button triggered!");
RaycastHit hit;
// if(Physics.Raycast(headGameObject.GetComponent<GvrHead>().Gaze, out hit, Mathf.Infinity)){
if(Physics.Raycast(cameraGameObject.transform.position, cameraGameObject.transform.forward, out hit, Mathf.Infinity)){
Debug.Log("Collision detected!");
}
};
}
“Button triggered!” is shown in the Console. Unfortunately “Collision detected!” is not. However the Pointer Click Event Trigger is working correctly (the component attached in the inspector). How can I know what is going on? Why isn’t it working?
Moreover, these are my attempts to see Debug.DrawRay working. I cannot see any line drawn:
Debug.DrawRay(cameraGameObject.transform.position, cameraGameObject.transform.forward, Color.green, 2, false);
Debug.DrawRay(cameraGameObject.transform.position, cameraGameObject.transform.forward, Color.yellow, 2, true);
Debug.DrawRay(head.GetComponent<GvrHead>().Gaze.GetPoint(0), head.GetComponent<GvrHead>().Gaze.GetPoint(5), Color.red, 2, true);
Debug.DrawRay(cameraGameObject.transform.position, cameraGameObject.transform.forward, Color.green, 2, false);
Ray ray = Camera.main.ViewportPointToRay (new Vector3(0.5f,0.5f,0f));
Debug.DrawRay(ray.origin, ray.direction * 100, Color.white);
Debug.DrawRay(ray.origin, ray.direction * 10);
Debug.DrawRay(ray.origin, (ray.direction + new Vector3(0.1f,0.2f,0.3f)) * 10);
Ray ray2 = cameraGameObject.GetComponent<Camera>().ViewportPointToRay (new Vector3(0.5f,0.5f,0f));
Debug.DrawRay(ray2.origin, ray2.direction * 100, Color.white);