x


How is Mouse Input Handled by Unity?

I'm thinking about writing a simple FPS in Unity. For the type of game I want to make I need to have really responsive mouse input. How does Unity provide mouse input on Windows (other platforms are less important)? I'm guessing Unity uses DirectInput. If so, is there any additional input lag created by Unity compared to using DirectInput directly?

Quake Live allow Windows users to either use DirectInput or raw USB device polling to read mouse input. Will Unity allow me to do my own input reading, e.g. link to DirectInput or poll the USB device?

more ▼

asked Feb 21 '10 at 05:07 PM

Anders E gravatar image

Anders E
1 1 1 2

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

2 answers: sort oldest

You can get the raw input for a given axis using Input.GetAxisRaw:

new Vector3(Input.GetAxisRaw("Mouse X"), Input.GetAxisRaw("Mouse Y"), 0);

This is different from Input.GetAxis in that there is no smoothing applied to the input.

more ▼

answered Feb 23 '10 at 10:12 AM

runevision gravatar image

runevision ♦♦
8.1k 29 46 112

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

you can read input from USB with a DLL, it's not possible in unity API. but hey why you should do that. the API is fast enough and support all mouse types including but not limited to USB devices. in web player unity uses javascript to get keyboard and mouse input. in EXE builds and editor it might use or or any other library but the important factor is you can get the raw mouse input and also smooth input. for a FPS you should use the raw input. you can use any API you want in a DLL and then call your DLL functions in unity but you really don't need it.

more ▼

answered Feb 23 '10 at 12:52 PM

Ashkan_gc gravatar image

Ashkan_gc
9k 33 56 117

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

x981
x948

asked: Feb 21 '10 at 05:07 PM

Seen: 4661 times

Last Updated: Feb 21 '10 at 05:07 PM