- Home /
IspointerOverGameobject does not work on TouchPhase.ended
hello everyone, I am working on a game . Everytime I tap and lift my touch , Gun in the game shoots a bullet, but i dont want to shoot when i touch A UI Object. So i Decide to Use Eventsystem.current.isPointerOverGameobject(). I pAss A touchFingerID , everyThing Is working fine if i use TouchPhase.Began or TouchPhase.Moved or stationary but doesnot work on TouichPhase.ended.. I also searched this problem on unity forum and i find this Thread https://answers.unity.com/questions/1269579/ispointerovergameobject-doesnt-work-on-touchphasee.html
Answer by chetan312 · Jun 30, 2020 at 08:29 AM
this is my script
if (Input.GetMouseButtonUp(0)) {
{
//check for touch ui
if (Input.touchCount > 0 && Input.touches[0].phase == TouchPhase.Ended )
{
if (EventSystem.current.IsPointerOverGameObject(Input.GetTouch(0).fingerId))
{
// Debug.Log("Clicked on the UI");
return;
}
}
//IsBuletactive = true;
FindObjectOfType<AudioManager>().P_Play("Shoot");
GameManagerStatic.Gamemanager.BulletUsed += 1;
BulletInstance( ) ;
}
}
Your answer

Follow this Question
Related Questions
Detect touches on ui element 1 Answer
TouchPhase.Ended not firing? 3 Answers
Touch inputs Angry-bird style 0 Answers
My dragging script "Sucks" all the other objects when touching it 1 Answer