Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 /
avatar image
1
Question by LeetRooster · Jul 20, 2013 at 08:52 PM · inputinputmanagerinput.getaxis

Why does InputManager have multiple axes with the same name?

By default there seem to be a few axes which the input manager has multiple copies of. They are even visible here: http://docs.unity3d.com/Documentation/Components/class-InputManager.html

For example there are two instances of Horizontal, Vertical, File1, ...

  1. How do you know which one you are referring to when you use Input.GetAxis("Horizontal")

  2. Why are they there by default are they supposed to represent a second player's controller or something?

This is a bit confusing and I was surprised to not find other users asking about this when I searched.

Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
3
Best Answer

Answer by Eric5h5 · Jul 20, 2013 at 08:54 PM

So you can have input from more than one source without having to write any extra code. In the case of the two default Horizontal axes, for example, one is for the keyboard and the other is for joysticks. You can't distinguish between them; the point is that you don't have to.

Comment
Add comment · Show 4 · 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 Xonatron · Jan 27, 2018 at 02:07 AM 0
Share

Can you clarify how Input.GetAxis("Horizontal"), for example, references only one or the other? Or perhaps I am understand this wrong. Can you help clarify how this works?

avatar image Eric5h5 Xonatron · Jan 27, 2018 at 02:11 AM 0
Share

It doesn't reference only one or the other, that's the point.

avatar image Bunny83 Xonatron · Jan 27, 2018 at 05:40 AM 1
Share

To clarify a bit more it does reference both at the same time. So pressing "D" (for moving left) will make the Horizontal axis to snap to "+1" while pressing "A" (for moving right) will return the value "-1". At the same time when any x-axis of any attached joystick is tilted to the right it would also return a value of "+1".. Of course mixing joystick input and pressing D or A at the same time might cancel each other. However that's not much different from pressing D and A at the same time.


If you don't want this behaviour feel free to remove any axis you don't want or if you want those input values seperate just rename one of the axes.

avatar image Xonatron Bunny83 · Jan 28, 2018 at 12:17 AM 0
Share

Got it. It reads them both. Now I completely got it!

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

18 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

Related Questions

Joystick Axis 9&10 with more than 2 gamepads 0 Answers

Quirk in Input.GetAxis 0 Answers

How do I add a value to anywhere Input.GetAxis("Horizontal") is called? 1 Answer

Input Snap option not returning 0? 0 Answers

input resets after scene change,Held Down Input not responding after scene change. 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