Game Object moved by mouse x,y input is limited to screen resolution. How to bypass for endless moving?

function Update () {

transform.position.x = (Input.mousePosition.x*0.05);
transform.position.z = (Input.mousePosition.y*0.05);
}

With his code I can move my object around but its constrained by the edges of the screen. How can I bypass these edges so i can move endlessly in any direction?

The reason why I'm using this kind of navigation is because I have made a device with a big ball, if you spin this ball in a certain direction a sphere in game will roll in the same direction.

Thanks in advance

2 Answers

2

You could add/substract the mouse delta to the object's transform.position, something like this:

function Update () {
  transform.position.x += (Input.GetAxis("Mouse X") * 0.05);
  transform.position.z += (Input.GetAxis("Mouse Y") * 0.05);
}

Thanks! Works like a charm.