2
\$\begingroup\$

After trying out a lot of stuff I finally need to surrender. Im having a project where I want to use the triggers of the Xbox Controllers seperately. To do so I added them as axis 9 and 10 in the input manager (see image). Now, when i have multiple controllers connected on project startup the triggers wont get recognized. I have to press the trigger on two controllers to get a value from it...prettty strange. If i reconnect the controllers after project launch everything works fine...

Input

Test script looks like this. Script

Thanks!

\$\endgroup\$
1
\$\begingroup\$

I had the same issue on our third person local co-op shooter game and I've burned countless hours only to conclude that it's bugged. I recommend ditching Unity's InputManager and use XInputDotNet (https://github.com/speps/XInputDotNet). Using this lib instead fixed all the issues I had with multiple controllers and trigger buttons. One caveat: it's not going to work on the OSX. As an alternative, you can then try XBoxCtrlrInput lib. It boasts OSX support but I can't fully vouch for it as I've only used it briefly (https://github.com/JISyed/Unity-XboxCtrlrInput).

\$\endgroup\$
  • \$\begingroup\$ My biggest issue with Unity's InputManager was that, depending on the order of controller connection, the axes for trigger buttons would become mixed up. TriggerAxis1 would become the axis for joystick2 and TriggerAxis2 would become the axis for joystick1, resulting in one player being able to partially control other player's character. \$\endgroup\$ – mt_ Dec 10 '18 at 19:13
  • \$\begingroup\$ Thanks for pointing out its a bug, I was going crazy searching for my mistake... Does XInput provides up to 8 controllers ? I tried it out already but because of their weird idea of passing a PlayerID as an enum I thought it wouldn’t be possible \$\endgroup\$ – DasMork Dec 10 '18 at 20:38
  • \$\begingroup\$ Sorry, I wasn't aware of the "up to 8 controllers" requirement. You could try modifying the enum and adding the additional players. The lib casts the enum to a uint anyway and eventually passes the value to xinput dll. \$\endgroup\$ – mt_ Dec 12 '18 at 5:48
  • \$\begingroup\$ Yeah I already did that. I completely removed the enum and changed the function parameters to already be unsigned ints. But this doesn’t change anything it seems, but that would mean xinput.dll can only handle up to 4 controllers so obviously I’m doing something wrong. \$\endgroup\$ – DasMork Dec 13 '18 at 7:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.