- Home /
How to avoid 2 fingers touch in android?
Hi everyone!
I'm using this bit of code on the main camera to simulate onMouseDown on android.
#pragma strict
function Update () {
var hit : RaycastHit;
for (var i = 0; i < Input.touchCount; ++i) {
if (Input.GetTouch(i).phase == TouchPhase.Began) {
// Construct a ray from the current touch coordinates
var ray = camera.ScreenPointToRay (Input.GetTouch(i).position);
if (Physics.Raycast (ray,hit)) {
hit.transform.gameObject.SendMessage("OnMouseDown");
}
}
}
}
It works fine BUT it's only working when i touch the object whit two fingers.
Anybody knows why?
Answer by moghes · Jan 23, 2014 at 03:47 PM
It must be from the preincrement of i.
Do the same with a post increment, i.e instead of ++i , do i++.
++i means increment then do the action, while i++ means do the action then increment.
Hope this solves.
I thought it would be that but after changing ++i to i++, I get the same issue.
thank you anyway ;-)
Your answer
Follow this Question
Related Questions
two input touch android 1 Answer
Click Two objects At Once Windows 7 Touch 1 Answer
How to determine input device being used? 0 Answers
Viewing Vectrosity lines from multiple cameras 1 Answer
Touch / mouse code. 1 Answer