x


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

more ▼

asked Apr 06 '11 at 02:58 PM

Flashbulb gravatar image

Flashbulb
2 1 1 2

(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

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);
}
more ▼

answered Apr 06 '11 at 03:59 PM

efge gravatar image

efge
5.1k 5 14 40

(comments are locked)
10|3000 characters needed characters left

Thanks! Works like a charm.

more ▼

answered Apr 06 '11 at 04:25 PM

Flashbulb gravatar image

Flashbulb
2 1 1 2

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x3570
x1001
x13
x8
x2

asked: Apr 06 '11 at 02:58 PM

Seen: 1326 times

Last Updated: Apr 06 '11 at 02:58 PM