Hi, i want to detect a mouse click on a especific object using raycast, but for some reason my code detects all the objects that have a collision when you click on them, here is my code.
if(Input.GetMouseButtonDown(0))
{
Vector2 MousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
RaycastHit2D Hit = Physics2D.Raycast(MousePos,Vector2.zero);
if(Hit)
{
gameObject.GetComponent<Animator>().SetBool("Push", true);
MouseDown = true;
}
}
Thank you.