So, I tried getting the XY pos of the mouse on screen like this:
RaycastHit2D hit = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector2.zero);
if(hit.collider != null)
{
Debug.Log ("Target Position: " + hit.collider.gameObject.transform.position);
PosXY=new float[]{hit.collider.gameObject.transform.position.x,hit.collider.gameObject.transform.position.y};;
}
However, bith X and Y are 0, and it doesn’t log anything. Anybody know why?