IsPointerOverGameObject doesn't work on my android
Hi, I have a little issue about the Input System on Android.
My player should turn towards the last touch. But i only want him to turn if the touch isn't on an UI Element.
For this i've searched the internet and come to this.
But my player turns towards the touch even if it's on a Button. Why?
if (Input.touchSupported)
{
foreach (Touch touch in Input.touches)
{
if (EventSystem.current.IsPointerOverGameObject(touch.fingerId))
return;
float dx = transform.position.x - Camera.main.ScreenToWorldPoint(touch.position).x;
float dy = transform.position.y - Camera.main.ScreenToWorldPoint(touch.position).y;
}
}
transform.eulerAngles = new Vector3(0f, 0f, Mathf.Atan2(dy, dx) * Mathf.Rad2Deg + 180);
Comment
Your answer
Follow this Question
Related Questions
Black UI when building to android 1 Answer
InputField problems on Android 1 Answer
How to edit Cardboard VR default UI 0 Answers
Use Android default sound effect on a button 0 Answers
Android UI push Multiple buttons Help 0 Answers