- Home /
Axis inputs mixed between controllers in build version
I ran into a problem while adding local play support to our multiplayer game, involving inputs. The trigger keys are working in the editor, but when I build and test the triggers are either ignored or listening to another controller. I'm testing with XBox One controllers, connected with USB cable, using official drivers. When I'm setting up the inputs it seems like 3rd axis is both triggers, negative being left and positive being right. But I want to be able to press both triggers at the same time, so I'm using 9th and 10th axis which are left and right triggers separately.
But it seems like the only time RightTriggerX triggers is when I press up with the right stick on that controller and press the right trigger on another specific controller. But, as mentioned, this is working correctly in the editor, the problem occurs when I try a build version. This is how I check the inputs:
public enum PadAxis {
None, LSVertical, LSHorizontal, RSVertical, RSHorizontal, DPHorizontal, DPVertical, LeftTrigger, RightTrigger
}
public static float getRawInput(PadAxis axis, int joypadID) {
float result = Input.GetAxisRaw(axis.ToString() + joypadID);
//temporary log test
if (Mathf.Abs(result) > 0.9f) {
Debug.LogError(axis.ToString() + joypadID + " is pressed");
}
return result;
}
Does anyone have an idea where the problem could be?
Edit: Using Unity version 4.5.5f1
Edit 2: I created a new project to see what would happened, and 9th and 10th axis did not react to anything. After going back to the real project the same issue happens in the editor as I described in the build. I'm almost certain I changed nothing in the code, so I have no idea where that came from.
Same thing is happening to me, I´m using the latest build Unity5.2.2, did you solve this problem by any chance?
Answer by JuriKnauth · Feb 16, 2018 at 10:20 PM
2017.3.0f3 here. Yes its still an issue. Still wondering. Solution so far for me - don't use both triggers...
Answer by ethentianknight · Mar 19, 2018 at 11:56 PM
Currently running into the same issue. On build only, my triggers shuffle between controllers.
Answer by PartTimeMonkeyExtra · Mar 23, 2018 at 01:04 PM
Any update on this? Just ran into the same issue. Unity 2017.3.1p1,Any update on this? Just ran into this as well. Very annoying. Unity 2017.3.1p1
No updates. I imported XInput and stopped using Unity's input. Nice to hear this is still an issue 4 years later.
No news yet. I have reported the bug and Unity said that they were able to reproduce the bug. Haven't heard anything since.
I put an example up on my git. link text
Further testing with a colleague lead to following observations/assumptions.
The error seems to appear randomly (If it does it's impossible to solve: rebuilding/re-plugging and rebooting won't have an effect). However next day it is impossible to reproduce the bug and yet even later it can be reproduced again.
See$$anonymous$$gly at least two controllers are needed and if the error occurs the input of at least two players seem to be faulty.
What appears to be happening is that the Triggers (Axis 9 and 10) are swapped with another player. There is a possibility that not only two players will swap the input of these two triggers but all their inputs get swapped. (e.g.: Player A has Triggers of B, while B has them of C and C has the Triggers of A)
Furthermore these inputs of a swapped Trigger are only registered - if any other Input is triggered on the original controller as well. (e.g.: Player A and B have swapped inputs. A's axis 9 and 10 however are only registered if B presses them on his controller AND A presses any other button on his controller at the same time.
^^ Truly any other button can be pressed - even buttons which are not mapped in the Input-Editor of Unity.
Oh the bug can be reproduced within the editor of Unity and not just within the build application.
The order of the plug-ins don't seem to effect the bug. It is a good idea to initialize every controller one by one - but this doesn't seem to solve the problem either.
Sadly the input handling of unity is not reliable/robust when a Xbox controller is used. So I would recommend writing your own Input $$anonymous$$anager and import it to Unity. I haven't done so yet - but I thought about doing it some time in the future - if so I would gladly share it.