Multitouch second touch interrupts first, BUT is fine if the first touch is the third touch. WHAT!?
Hi all
I'm working on an Android touchscreen game. Left side of the screen steers, right side of the screen has buttons that do other stuff. Seems straightforward enough.
What I have: Left touch steers, but when I touch the right side, the first touchpoint is interrupted. The fingerId is still maintained, but moving that finger no longer updates the input number.
Bizarro behaviour: If I put two or more fingers on the screen FIRST (to the right of the screen), then start steering on the left side, THEN add more touch points on the right, the steering does NOT get interrupted. One finger first doesn't prevent the interruption, only two or more.
The last line is a debug that tracks the number of fingers on the screen and the fingerId of the movement finger. Both numbers track correctly.
Why!??! Help!!! Thanks!!!
My code:
for (int i = 0; i < Input.touches.Length; i++)
{
//if no fly finger assigned and touch is on the left side
if ((flyFingerId == -1))
{
if (Input.GetTouch(i).position.x < Screen.width/2)
{
switch (Input.GetTouch(i).phase)
{
case TouchPhase.Began:
// code to run when touch begins here...
controlType = UseControlType.Mouse;
touchPointStart = Input.GetTouch(i).position;
flyFingerId = Input.GetTouch(i).fingerId;
break;
}
}
} else
if (Input.GetTouch(i).fingerId == flyFingerId)
{
switch (Input.GetTouch(i).phase)
{
case TouchPhase.Moved:
case TouchPhase.Stationary:
// code to run when touch is being dragged here...
touchPointOffset = touchPointStart - new Vector2(Input.GetTouch(i).position.x, Input.GetTouch(i).position.y);
break;
case TouchPhase.Ended:
case TouchPhase.Canceled:
flyFingerId = -1;
touchPointStart = Vector2.zero;
break;
}
}
}
Debugui.text = "touches: " + Input.touches.Length.ToString() + " / flyfingerID:" + flyFingerId.ToString();
Your answer
Follow this Question
Related Questions
Why is my first touch interpreted as a mouse click? 0 Answers
How can convert keyboard controller to touchscreen(android .ios ...etc) 1 Answer
Rotate Player w/Touch Input Controls 0 Answers
Problem with Swipe and rb.MovePosition 0 Answers
How can I change my player control method to use a touch screen ?? Pong-clone 2D 0 Answers