I have been making an iOS app and been using mousebuttondown for my raycasts which works fine. However if someone accidently has an extra finger on the screen it no longer works. Is it possible to handle multiple touches which a raycast easily? Thanks
Can you post your code you are using for this? You might need to run your touch functions in a for loop but not 100% sure what you have.
Perhaps something like this? Code (csharp): for (var i : i in Input.touches) { if (i.phase == TouchPhase.Began) { raycast(); } } I'm not at my home computer so no way to test, sorry.
Code (csharp): if (Input.GetMouseButtonDown(0)) { //empty RaycastHit object which raycast puts the hit details into var hit : RaycastHit; //ray shooting out of the camera from where the mouse is var ray : Ray = cameraInterface.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, hit)) thanks for the suggestion, i will give it a go. I know I need to convert to unityscript but I will give it a go
Im ten years later but try this Code (CSharp): if (Input.touchCount > 0 && Input.GetMouseButtonDown(0)) { raycast(); }
This should do the trick Code (CSharp): if(Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Began) { // Do something }