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