- Home /
Question by
Häferlprinz · May 02, 2014 at 06:48 PM ·
inputtouchscreenmultitouch
Problems with multi touch for loop (touchCount)
Hi!
Got some problems to get a multitouch to work properly:
if i start with finger 1 on touch it works. if i put finger 1 on touch and then put finger 2 on touch, without moving finger 1 away it works as well. but when i remove finger 2, so that finger 1 is still left on the touch, debug states that touchCount = 0, but i need to get the touchCount back 1 or execute the code from Input.touchCount==1 (see below), without moving all fingers away from touch.
Is there something wrong in my code or does anyone no a way to achieve this?
void Update() {
for (int i = 0; i < Input.touchCount; i++) {
if (Input.touchCount == 1){
if(Input.GetTouch(i).phase == TouchPhase.Moved ||
Input.GetTouch(i).phase == TouchPhase.Stationary){
//Do something
}
}
if (Input.touchCount == 2) {
if(Input.GetTouch(i).phase == TouchPhase.Began) {
// Do something else
}
}
}
}
Comment