Raycast on mouse position problem. how not to raycast to 0

Hi, i try to drop objects from ui into 2d world using raycasting. Object is dropped on the good layer but in a wrong place. Dropped item always shows up on coordinates x=0, y=0, z=0 insted of mouse position in world. i know something is wrong, propbably RaycastHit is not defined but im not sure how to fix this and would apreciate some help

       public Camera cam;
          public virtual void OnDrop()
              RaycastHit hit = new RaycastHit();
              Ray ray = cam.ScreenPointToRay(Input.mousePosition);
              if (Physics.Raycast(ray, out hit, 0))
                  gameObject.transform.position = hit.point;

You’re code should work just fine - I just tested it myself. There must be something else going on. Is gameObject a child of some other gameObject? If you debug hit.point, what value do you see?