- Home /
Question by
Flashbulb · Apr 06, 2011 at 02:58 PM ·
javascriptmouseendlessobjects-movementxy
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
Comment
Answer by efge · Apr 06, 2011 at 03:59 PM
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);
}
Your answer
![](https://koobas.hobune.stream/wayback/20220613121109im_/https://answers.unity.com/themes/thub/images/avi.jpg)