- Home /
Touch recognition problems with IPhone 6s.
The following code is supposed to oben a UI element when a object in the scene is touched. Pretty straightforward isnt it. Nevertheless by testing it on different IOS devices i discovered strange problems. So this code works as expected on iPhone4s, iPhone5s, IPad3, IPad Air2, IPhone6 but NOT on the Iphone6s! The touch recognition in completely of. Sometimes It reacts on very 'slight' touches (like barely touching the display at all) Most of the time it ignores the 'block-raycast-through-ui-elements' funcion as well. So it's kinda weird all over the place. Does someone have any experience with that problem? I'm very desperate by now.
void Update()
{
if (Input.touchCount == 1 && gameIsReady == true)
{
touch = Input.GetTouch(0);
Vector3 p = cam.ScreenToWorldPoint(new Vector3(touch.position.x, touch.position.y, 0.0f));
if (touch.phase == TouchPhase.Began)
{
if (EventSystem.current.IsPointerOverGameObject(Input.GetTouch(0).fingerId))
{
fingerOverUI = true;
}
else
{
fingerOverUI = false;
}
moved = false;
}
if (touch.phase == TouchPhase.Moved)
{
moved = true;
StopAllCoroutines();
FloatingUI.SetActive(false);
panelIsOpen = false;
}
if (touch.phase == TouchPhase.Ended && moved == false && fingerOverUI == false)
{
hit = Physics2D.Raycast(new Vector2(p.x, p.y), Vector2.zero);
if (hit.transform.tag == "Country" && panelIsOpen == false)
{
clickedCounty = hit.transform.name;
FloatingUI.SetActive(true);
panelIsOpen = true;
StartCoroutine(moveCamToCountry(hit.transform.name));
StartCoroutine(displayFloatingStats(hit.transform.name)); //Open the UI I element.
moved = false;
}
else if (panelIsOpen == true)
{
FloatingUI.SetActive(false);
panelIsOpen = false;
StopAllCoroutines();
}
}
}
else if (Input.touchCount > 1 && gameIsReady == true)
{
StopAllCoroutines();
}
}
Your answer
![](https://koobas.hobune.stream/wayback/20220612080756im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Delta touch trembling 0 Answers
How can I get the exact iphone screen touch position? 2 Answers
Simultaneous Touch Drag Controls 0 Answers
Multi touch not working on iOS (does work on Android) 1 Answer
Scripting a "touch" on an object in iOS. 3 Answers