Raycast behavies as if its snapping to grid on standalone build

I am using raycast to locate a GameObject in worldspace i.e. I am casting a ray from my UI camera and taking its hit.point as the new location for my object.

This works nice and smooth when ran in the editor however when I build and test in stand alone the object moves as if its snapping to a grid.

I set up a few messages to see the results of the case; in editor I see [Note gradual change to the y value]

Mouse @749,949 cursor move to 9992.822,10070.4,10108.08

Mouse @751,950 cursor move to 9993.35,10070.61,10108.08

Mouse @754,952 cursor move to 9993.983,10070.93,10108.08

in build I see [Note the 3+/- unit change in the y value]

Mouse @887,993 cursor move to 9994.194,10054.46,10108.08

Mouse @887,994 cursor move to 9994.194,10057.95,10108.08

Mouse @887,995 cursor move to 9994.194,10057.95,10108.08

Mouse @887,996 cursor move to 9994.194,10057.95,10108.08

Mouse @887,997 cursor move to 9994.194,10057.95,10108.08

Mouse @887,998 cursor move to 9994.194,10057.95,10108.08

Mouse @887,999 cursor move to 9994.194,10057.95,10108.08

Mouse @887,1000 cursor move to 9994.194,10057.95,10108.08

Mouse @887,1001 cursor move to 9994.194,10057.95,10108.08

Mouse @887,1002 cursor move to 9994.194,10057.95,10108.08

Note from mouse.y 993 to 994 the world pos moved 3.9 units; from 995 to 1002 it didnt move at all. The plane I am aiming at is 109 units out from the camera and for this test level with the camera such that the object should move up and down, left and right but not in and out.

Code in question


Ray ray = MainCamera.ScreenPointToRay(Input.mousePosition);
      		RaycastHit hit;
         	if(Physics.Raycast(ray, out hit, CursorLayers))
    		{
            	CursorPosition.transform.position = hit.point;
    			Debug.Log("Mouse @" + Input.mousePosition.x.ToString() + "," + Input.mousePosition.y.ToString() + " cursor move to " + hit.point.x.ToString() + "," + hit.point.y.ToString() + "," + hit.point.z.ToString());
    		}

I have tested the build at a number of diffrent resolutions the exsact results are diffrent but always jumps by a couple of units while the in editor run always moves smooth.

I’ll keep digging on it my self but any pointers or tips would be much appreciated.

Thanks

Found the answer;

The casue of this behaviour is the near clip; I had set my GUI camera near to 0.01f; did this so that objects passing through the screen wouldnt get cliped till the last second draw back is that rays are cast from the near through the pixel location of the mouse and apparently to only 2 points of perision which causes them to hop on a grid that is roughly 100 by 100 (I’m guessing) when the near is set to 0.01;

I adjusted my near to be as far out as I can tollerate for this camera and everything smoothed right out. Now why this causes the in accuracy in the ray cast in the build but not the editor I’m not sure.