x


Mouse wheel working in web player but not in stand alone

Hi! I'm having trouble using the mouse wheel. I have a simple rts camera control script in which I use the mouse wheel to zoom in and out. Like so:

transform.Translate(0,0,Input.GetAxis("Mouse ScrollWheel") * transform.position.y);

The problem is that it works fine in the editor game window and web player but if I make a stand alone build the wheel does nothing. I also use the wheel button to focus the camera on an object and make the camera follow it but that doesn't work in stand alone either. All other controls work fine.

more ▼

asked Dec 12 '09 at 05:34 PM

Wertymk gravatar image

Wertymk
1 1 1 1

Well, I got it working though I don't really understand where the problem was. I moved all the actual camera movement under FixedUpdate and use Update just to check for button presses. I'd appreciate it if someone could explain what the problem was, so I can avoid similar problems in the future. I know FixedUpdate is called every physics step and Update every frame but...

Dec 12 '09 at 06:39 PM Wertymk
(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

Input is handled in the Update loop.

Update() runs as many times per frame as it can (although it is clamped to 50fps in the editor and web player).

FixedUpdate() always runs at the current Time interval, default is 50fps, I believe.

If you only test for input in the Fixed Update loop it is possible that 2 Update frames occur for each FixedUpdate() frame (your game is running at 100fps, in this example).

If on the first Update you click, the second Update will clear that click, and then when FixedUpdate runs, it will say 'there aren't any clicks' - hence input is broken.

Since the editor and web player are clamped to a lower speed, you are less likely to have this problem, however your own solution is best. Test for input in Update(), not FixedUpdate().

more ▼

answered Dec 27 '09 at 05:49 AM

Brian Kehrer gravatar image

Brian Kehrer
2.8k 9 11 50

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

i have problems like this if i accidently made a change to the settings in a stand alone build of the game, at the screen that pops up before the game,so when that window pops up, look into its controls and just check its settings out, I do not, however, know if even appears there..

more ▼

answered Dec 12 '09 at 06:17 PM

m50 gravatar image

m50
76 2 3 5

(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:

x984

asked: Dec 12 '09 at 05:34 PM

Seen: 1740 times

Last Updated: Dec 12 '09 at 05:34 PM