Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
0
Question by siliconpi · Sep 05, 2019 at 08:25 AM · mouseinput.getaxisunitsmaximumminimum

How to determine the maximum and minimum values of Input.GetAxis("Mouse X")?

I'm trying to determine what would be the maximum and minimum values of:

 Input.GetAxis("Mouse X")
 Input.GetAxis("Mouse Y")
 Input.GetAxis("Mouse ScrollWheel")

By observation, I've determined that my mouse's ScrollWheel range of values is exactly (-0.5, 0, 0.5).

On my machine I can write code to capture these values when I move the mouse rapidly, but how can I determine that concretely on a user's machine?

Can I read these values from the system?

Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Hellium · Sep 05, 2019 at 08:00 AM 1
Share

The documentation is your friend:

https://docs.unity3d.com/ScriptReference/Input.GetAxis.html

Returns the value of the virtual axis identified by axisName.

The value will be in the range -1...1 for keyboard and joystick input. If the axis is setup to be delta mouse movement, the mouse delta is multiplied by the axis sensitivity and the range is not -1...1.

avatar image Bunny83 Hellium · Sep 05, 2019 at 08:33 AM 0
Share

I moved this question to the help room since you just rejected it a second before I tried to post my answer ^^.


While I agree that the documentation gives some hints about delta values, it's however not clear if it's just a larger range or if it's actually unbounded. Pure negate logic only works on boolean conditions. if it's not in range -1..1 does not imply it's unbounded. It could be 0..1 or -42..42 which all satisfies the condition not being the range -1..1 ^^.

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by Bunny83 · Sep 05, 2019 at 08:25 AM

There are no maximum values as those are all delta inputs. If you somehow manage to move your mouse 1 light year in a millisecond (assumed your mouse could still detect this movement) the value would be off the charts. The same is theoritically possible for the scroll wheel as well but since the "notches" of the scroll wheel are usually quite far apart and your update rate is relatively high you usually only ever see one notch movement at a time. However you can't really be sure what value you get for one notch as it depends on the hardware and sometimes even on the mouse settings in the OS.


In general delta values tell you how much the mouse / screll wheel has been moved since the last frame. Of course there are some hard limitations on how large the values can get. AFAIK most APIs and hardware send the relative delta as 16 bit numbers. Though specific hardware might use higher precision. Just as an example windows WM_MOUSEWHEEL message actually encodes the wheel delta in a 16 bit word as a multiple of 120. This allows for a delta of about "+-273 notches" per update. Nobody will be able to rotate the wheel that fast within a few milli seconds and no (common) hardware would be actually able to detect this ^^. Thouse with a mouse like this you might be able to get more than one notch per update and therefore higher delta values.


A lot software just ignores how far the wheel actually moved but they just determine if the delta was positive or negative. Personally I don't like this approach. Since the amount returned by Mouse X or the scrollwheel can vary heavily from device to device it's common to provide a sensitivity setting for the user to adjust.


Why would you ever want to know the maximum of a delta value anyways? If you just want to make sure that a single delta is not above a certain value, you might just clamp the value between certain limits you want for example to prevent cheating by a user who increases his mouse sensitivity in the OS which would allow him to get larger delta values with less actual movement.

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image siliconpi · Sep 05, 2019 at 09:51 AM 0
Share

Thanks @Bunny83 for the detailed reply. I'm using a wireless mouse on an Android device to control an object and slight movements of the mouse make the object shoot off. I was trying to deter$$anonymous$$e the "range" of mouse movements possible, so that I could "scale them down" and to make the corresponding "acceptable" object movements. I didn't want to hardcode values based on my hardware.

avatar image Bunny83 siliconpi · Sep 05, 2019 at 03:22 PM 0
Share

Right, that's why every operating system that handles mouse input and every FPS game has a sensitivity setting that the user can adjust the way he likes it. On many modern mice you can adjust the DPI of the optical sensor which will change the precision and usually the sensitivity as well. Depending on the game I also use very different mouse sensitivity settings. If I play $$anonymous$$ecraft or space engineers I use a moderate sensitivity. If I play Quake I have a high sensitivity (I can almost do a 360° turn with one move. I don't use mouse acceleration).


So it's impossible to get the "right" mouse speed for every possible hardware as what feels right depends on the user. So just provide a sensitivity setting.

Your answer

Hint: You can notify a user about this post by typing @username

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

Answers Answers and Comments

120 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How can I make a particle system with varying size, but a low chance of very large and very small particles? 1 Answer

Please help me! Correct script) , 0 Answers

Can you help me understand this script 0 Answers

Space Flight Simulator Turning Problems 0 Answers

Input.GetAxis going crazy when I click outside the game window 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges