I tried and tried again but can't seem to make it work - the raycast does detect the gameobject, and the code detects the mouse button being pressed as well. Shouldn't it technically be working? I'm so confused.
void Update()
{
RaycastHit hit;
Ray ray = cam.ScreenPointToRay(Input.mousePosition);
LayerMask mask = LayerMask.GetMask("PhysicalObject");
if (Physics.Raycast(ray, out hit, Mathf.Infinity, mask) && Input.GetMouseButton(0))
{
hit.transform.position = new Vector3(cam.ScreenToWorldPoint(Input.mousePosition).x, 1, cam.ScreenToWorldPoint(Input.mousePosition).y);
Debug.Log("hit");
}
}```