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
13
Question by SeanH · Oct 04, 2013 at 09:40 PM · inputcontrollerjoystickconflict

Multiple Local Controllers getting messed up.

I'm having a very persistent issue in the project I'm working on where the XBox controllers will get 'mixed up' in unity. For example, the player with Controller 1(according to the light on the controller) will move Player 2's character, but shoot for his own character.

Our input settings are set up so each player has his/her own set of inputs. We have a "Move_1" axis for player 1's movement, set to only take input from Joystick 1, yet when Joystick 2's thumbstick is moved it registers as "Move_1". This problem only happens in Unity, and checking the controllers directly in Windows or even playing other games works fine.

I have verified and re-verified that the numbers correspond correctly, i.e. "Move_1" SHOULD only be accepting input from "Joystick 1". However, it only accepts from "Joystick 2".

The only 'solution' we have found is to unplug all the controllers, close down and restart unity, then plug the controllers in one-by-one and wait for each one to initialize and move his player around before pluging in the next one.

Anyone have any idea what could be causing this? Thanks in advance.

Comment
Add comment · Show 4
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 motorn · Oct 14, 2013 at 06:50 PM 0
Share

Hello, Did you find a solution for this? I have basically the same problem, but for me it works in the editor but not in the built game.

avatar image SeanH · Oct 14, 2013 at 09:38 PM 0
Share

Unfortunately, no, I have not found the solution. It's at least somewhat comforting to know that I'm not the only person with this problem, at least.

At this point I'm seriously considering writing my own independent input manager with C# just to get around the problem.

avatar image ravage484 · May 04, 2014 at 09:40 PM 0
Share

Find a solution? I'm new to unity, and have just started working on a game that uses 4 players, set up similarly to yours (each player has their own axis and button set up in the input manager). No matter what I do, even when I restart Unity, or the Exe I've created, AND restarted my Xbox 360 wireless dongle AND the four controllers, I only have like a 50% chance that it will work properly..

avatar image SeanH · May 06, 2014 at 03:09 PM 0
Share

Unfortunately not. I have since moved on to another project, but if you do find a solution I would love to hear about it!

2 Replies

· Add your reply
  • Sort: 
avatar image
25

Answer by The_Spellmaker · Nov 02, 2014 at 06:41 AM

Hi, I realize this is an old post, but I still want to leave the documentation in case anyone (or myself in the future) has the same question.

1) The input manager has the Joy Num field. This works only for axes, not for buttons.

2) For buttons you have to write (without the quotes) "joystick [joystick #] button [button #]" in the "positive button" box

3) IMPORTANT - Unity doesn't necessarily map joystick 1 to the first controller. So if you have your XBOX controller with the green light on the first position, it doesn't necessarily mean that it will be mapped to joystick 1.

I found a solution to point 3, it's definitely not the best but it does work: first - map a lot of controllers in the input manager.

alt text

So you see that I have kHorizontal and also j1Horizontal, j2Horizontal (k for keyboard, j1 for joystick one etc). Then you ask the user to press a button in order to know what controller he has in his hand and store that in a variable. I used a string:

 public string controller;  // I store this in the Player class

Then have a place where you ask the user to press start and check what button he pressed and store that information in the controller variable that we defined before:

  if (Input.GetButton("kStart"))
     controller = "k";
 
  else if (Input.GetButton("j1Start"))
     controller = "j1";

Then, when you need to get input, concatenate the controller variable to the name of the button like so:

 void Update()
 {
 rigidbody2D.AddForce(Vector2.right * speed * (Input.GetAxis(controller + "Horizontal"));
 }

I'm sure there must be a better way, but this might get you going. Hope it helps.

Cheers,

Spellmaker


picture1.png (78.8 kB)
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 Whiteleaf · Mar 15, 2016 at 04:49 AM 2
Share

I hate to be that one guy that revives old threads, but thanks. This helped me a lot--first time learning controller support. By the way, this works with PS4 controllers. I'm not sure about Xbox One but I'd guess it's the same.

avatar image Bunny83 Whiteleaf · Mar 15, 2016 at 05:37 AM 3
Share

We appreciate feedback as long as it's more than a "thanks" ^^. Don't forget to vote. $$anonymous$$eep in $$anonymous$$d you can upvote the answer but also the question (and even comments). A lot people here on UA don't vote at all. $$anonymous$$ost who do vote, forget to vote the question as well. Without the question there wouldn't be an answer.

So if you see a good / helpful post (question, answer, comment) you should upvote them. Be careful with downvotes though. Downvoting should only be used when there's misinformation in a post. If you downvote you should leave a comment and explain what's wrong. If you downvote a post you as well as the post author will loose some karma.

avatar image nick_ta_mere · May 16, 2016 at 04:16 PM 0
Share

oh my god, thank you! I must've been trying to figure out what I did wrong for 2 hours! I thought there was something wrong with the script instances, because I configured the buttons just as I did for the axis(es?)

avatar image albertjames · Jun 16, 2019 at 11:49 AM 0
Share

O$$anonymous$$G... two days of life could have been saved by this. Thanks.

avatar image
9

Answer by kefrens · Dec 15, 2013 at 11:50 PM

It's quite simple but as usual Unity's documentation is incomplete.

Looking at input manager you need to define correct value for "positive button". It turns out that default "joystick button 1", "joystick button 2" catch button 1 and 2 on any connected joystick. If you need to receive input from i-th button on n-th joystick you should set "positive button" to "joystick n button i"

The field "Joy Num" is well.. misleading. :-)

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 SeanH · Dec 16, 2013 at 12:07 AM 0
Share

We did that for the buttons. Unfortunately the problem we're having is with the axis, which don't use the button field.

avatar image motorn · Jan 19, 2014 at 09:52 AM 1
Share

$$anonymous$$y problem was with the trigger axis on a 360 controller. They are supposed to be the 9th and 10th axis. But with that setting they got messed up in my builds. However if Im using the 3rd axis, one trigger goes from 0-1 and the other -1 to 0. Then it works as it should.

avatar image JuriKnauth motorn · Feb 16, 2018 at 10:21 PM 0
Share

motorn's solution works. It is still an issue in 2018. I wonder how i could use both triggers at once. If left-trigger "subtracts" and right-trigger "adds" the resulting Input is 0.

avatar image CaptainCam · Aug 07, 2017 at 10:35 PM 0
Share

THAN$$anonymous$$ YOU!

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

26 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

Related Questions

Unity only read the first connected Controller's input 0 Answers

Multiple Game Controllers At Once 0 Answers

Check whether specific joystick connected 0 Answers

Controller's data are not correct 0 Answers

Nonexistant joystick being detected 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