When I click the object, the first debug returns sensible numbers, and seems to work. However, the second always returns the position of the main camera, and nothing else. Anyone knows what am I doing wrong? Thanks!
That’s because your third parameter is 0. The third parameter means “distance from the camera”, so naturally if the distance from the camera is 0 it must be the position of the camera.
that’s what Manta meant about the third coordinate. That means “tell me the world point at this distance into the screen,” in the example I suggest above, distance = 10; Your mileage may vary.
Oh, I see what you mean. I thought the method would simply translate the provided Vector3 into a world coordinate, not do some kind of a raycast. Thanks a lot both!