I'm using the game to control electronics. I use the following code to determine the location of an object (the location is used to perform calculations that are sent to the electronics)
int centerX = Screen.width/2; int centerY = Screen.height/2; Vector3 centerVec = new Vector3(centerX, centerY); Vector3 diffFromCenter = Input.mousePosition - centerVec; Ray ray = Camera.main.ScreenPointToRay(centerVec + 0.5F*diffFromCenter);
This is used (along with a raycast to determine the appropriate
y value) to determine the location of the object.
The reason I use
0.5*diffFromCenter is because of the sensitivity of the movement (as seen in the reaction of the electronics)
The problem with this approach is that it when the (real) cursor reaches the edge of the screen and can't move further, the in-game object won't be able reach the edge of the game window.
The only idea I could come up with to solve this problem is to use code to change settings on the speed of the mouse's movement.
I can't come up with a better solution (and this one would require that I also detect when the cursor leaves the game window to restore the mouse movement speed, because we'll be running experiments and someone might need to tweak things during the experiment...)