Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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
2
Question by Anglish · Aug 17, 2012 at 10:12 PM · inputgetaxishorizontal

Input.GetAxis(Horizontal) problem

Wen i use Input.GetAxis("Horizontal") its pressing alone all by itself, i even tried unpluging the keyboard and nothing, this is a little code i used to figue it was failing:

 function Update () {
     
     if(Input.GetAxis("Horizontal"))
     {
         print("Input: " + Input.GetAxis("Horizontal"));
     }
 
 }

And what i get in the console whitout pressing any button is:

Input: -1

wish means its pressing to the left but i dont press any button.

the only diferent thing i did was update to 3.5.5f3

started the game and my character was waliking to the left o.O

i changed to previus version and the same thing keeps happenig, any ideas on what could be happening?

Comment
Add comment · Show 1
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 Eric5h5 · Aug 17, 2012 at 11:17 PM 0
Share

Did you unplug any joysticks/gamepads you might have?

6 Replies

· Add your reply
  • Sort: 
avatar image
6

Answer by mikedolan03 · Dec 02, 2014 at 12:39 AM

The best way to solve this from the programmer end is to write your input scripts to deal with it. Currently, your game (by default) accepts Hortizontal and Vertical Axis info from the keyboard or a joystick. They are labeled the same in the Input Manager... That way you can write code like:

  float translation = Input.GetAxis("Vertical") * speed;
  float rotation = Input.GetAxis("Horizontal") * rotationSpeed;

And it wont matter if the player is using a keyboard or a joystick. Unfortunately when a player has something going on with their joystick stuff (virtual joysticks seem to cause issues), the Axis gets all wonky... Players report spinning around that won't stop.

BUT... If you change the name of your second set of Horizontal and Vertical Axes in the Input Manager (the ones that correspond to the joysticks) to something like HorizontalJoy and VerticalJoy then they won't interfere for your keyboard-only using player. You could then add a toggle on your Controls or Pause menu to enable Joystick controls.

then you might write code like this:

 if( !joystick )
 {
  //if joysticks aren't enabled - just track keyboard axis 

  float translation = Input.GetAxis("Vertical") * speed;
      float rotation = Input.GetAxis("Horizontal") * rotationSpeed;
 } else {
 
  float translation = Input.GetAxis("VerticalJoy") * speed;
      float rotation = Input.GetAxis("HorizontalJoy") * rotationSpeed;
 }

Below is a screenshot of the input manager - notice the second set of Horizontal and Vertical Axis are called HorizontalJ and VerticalJ. Do something like that and write code to allow for joy support if you want to give your user the option and the bug should be fixed on your end and the users. This also means joys won't really be tracked unless you write code to watch the specific axis as stated above. This solution worked for my testers.

input manager screenshot


screen shot 2014-12-01 at 7.08.51 pm.png (36.8 kB)
Comment
Add comment · 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
3

Answer by aldonaletto · Aug 17, 2012 at 10:49 PM

It seems that the Horizontal axis Input settings have been screwed up - either by the Unity update or unintentionally by yourself. There are two Horizontal axes, one for button/key and the other for joystick input. Check if both Horizontal axes are set as below (default setting):

alt text

Comment
Add comment · Show 1 · 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 kiritaku · Jan 15, 2014 at 12:13 AM 0
Share

just ran into the same issue, except $$anonymous$$e was pushing right. turned out that the joystick part of Horizontal was reading 1.0 constantly. not really sure why, but by deleting the joystick copy (the 2nd horizontal entry,) it fixed my issue. obviously i need to re-enable joysticks at some point, but for my early testing stuff its fine :)

avatar image
2

Answer by solidearthvr · Aug 10, 2017 at 11:11 PM

Similar to @jinhyuki my problem was caused by an extra non-existent HID, in my case it was a "HID-compliant game controller" that was the culprit. alt text

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

Answer by jinhyuki · Feb 27, 2017 at 08:50 AM

Had a same problem.

My problem was fixed when I uninstalled virtual joystick I installed before, and disabled the virtual joystick driver.

alt text


disabled-vjoy.jpg (85.1 kB)
Comment
Add comment · 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
0

Answer by HisakoDarkFire · Aug 28, 2020 at 09:29 PM

My fix was to set Camera to MainCamera in the Tag section, NOT the name (for new people).

Comment
Add comment · 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
  • 1
  • 2
  • ›

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

16 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

Related Questions

How to have vertical and horizontal axis work at the same time 1 Answer

Horizontal as a NGUI button 0 Answers

Steering Wheel / joystick GetAxis trouble 0 Answers

Windows 8 touch equivalent for 'Input.GetAxis("Mouse X")' 2 Answers

Adapting Horizontal and Vertical movement to New Input System? 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