Raycast2D from camera does not hit objects


I am using Physics2D.Raycast to hit a 2d object, with vector zero as my direction.
However, the collider value is always null.
When I change the direction to other, for example Vector2.up, it does hit the object above the mouse click location.

this is my code:

Vector3 position = Input.mousePosition;
_hit = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(position), Vector2.zero);

And this is some raycast start location:

Camera location: (0,0,-10)

The Gameobjects that I try to hit has Z = 0 value.

I found the problem and the solution

I had to checked Queries Start In collider.
Edit → Project Settings → Physcis 2D → Raycasts Start In Colliders.
alt text

I have unchecked it in the past, so the 2DRaycast would not hit the object that create, but I didn’t know that its make a problem.

(here the post that I used to make the 2DRaycast not to hit itself: 2, but again, it created my problem)