Hey folks-
I am new to Vuforia.
I know this is not a new question and I have gone through each of the thread/post on this discussion blog for that matter but the problem still persists. And the problem seems very fundamental.
I have the following script attached to my gameobject :
void Update () { if (Input.touchCount == 1) { // Touches performed on screen Ray ray; RaycastHit hit; Debug.Log ("2"); if(Camera.main != null) { Debug.Log ("3"); ray = Camera.main.ScreenPointToRay(Input.GetTouch(0).position); hit = new RaycastHit(); Debug.Log ("33"); if(Physics.Raycast(ray, out hit)) { Debug.Log ("4"); } } } }
When I run the scene and touch on the gameobject, the Debug Console shows
2
3
33
BUT NOT 4. Somehow this ray doesn't hit the object.
This script works fine with the normal camera. Could anyone please shed some light on this.
Thanks
Hi @mazher @mocom,
I've used the example code from Physics.Raycast Unity Scripting API, counted the hits and added an UI to show me on the device if it's happening or not. I can confirm it works as expected.
code below:
I've added the script to the ARCamera.
Tested on an Android Device.
Hope it helps.
Thank you.
Vuforia Engine Support