I worked with unity for a while then took a big break, returned to my old project and I don’t understand why I constantly select my 2D object when in theory I shouldn’t? how do i test the click on its collider. in 3D I can figure it out, but in 2D it doesn’t work
var result = Physics2D.Raycast(Vector2.zero, myCamera.ScreenToWorldPoint(Input.mousePosition));
if (result)
{
Debug.Log("I AM CLICKED ONTO " + result.collider.name + " with this position " + predictionPosition);
if (result.collider.name != "GameBoardManager")
return;
}
why my code doesnt work. why i every time hit gameboard manager.