Collision Detection working on PC but not on Mobile
Hi , I am working on an Android/Mobile game , and it is almost done except for one bug that I don't have an answer . In my game , I need to click on some geometric forms to destroy them . It is all working perfectly on PC , when I click on them they got destroyed on the first click as they should , but when I tested the game on my Android , the forms don't always destroy on 1 click/touch as they should .
I think maybe is the engine that not checks collisions every frame , but I am not sure beacuse if it was this I think the forms wouldn't always destroy on the first click on the PC too.
Also , this is the code that I use to check if I clicked/touched a form :
if (Input.GetMouseButtonDown(0)) { RaycastHit2D hit = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector2.zero);
if (hit.collider != null)
{
if (hit.collider.gameObject == gameObject)
{
Destroy(gameObject);
Instantiate(effect, transform.position, Quaternion.identity);
}
}
}
Your answer
![](https://koobas.hobune.stream/wayback/20220613012834im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How to separate a Tap from a Swipe? 0 Answers
Code help with mobile touch drag 3D Top Down 0 Answers
Drag UI by touch 2 Answers
Spawning enemies after death help 0 Answers
How to detect the touch on certain Game Object (UI Panel) 1 Answer