I have a problem, I have a 3D animation and I added two colliders
I did this because I want to detect when the user touch the head, the chest or the abs zone. And as the picture shows, in the chestUpper zone I add a sphere collider, in the hip and head too. I have colliders and I have this script
public class OnTouch : MonoBehaviour
{
public int cuerpo = 2;
void Update ()
{
if (!Input.GetMouseButtonDown(0)) return;
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;
Debug.Log("entre");
if (!Physics.Raycast(ray,out hit)) return;
Debug.Log("entre2");
Debug.Log(hit.collider.name);
if (hit.collider.name == "head") { }
else if (hit.collider.name == "chestUpper") { }
else if (hit.collider.name == "abdomenUpper") { }
else if (hit.collider.name == "hip") { }
}
}
The problem is that sometimes I detect the mouse when I run it in unity, SOMETIMES.. And when I build and run the project to my cellphone, always detect the head, but the others colliders are not detected. How can resolve this?