- Home /
Unity only read the first connected Controller's input
Hello,
I am having big trouble with inputs, although I thought having implement all correctly...
Here is my actual problem, I have a simple script that do that just in order to see if the controller works
public class InputManager : MonoBehaviour
{
public const float MAX_CONTROLLER = 2;
public List<int> assignedController = new List<int>();
void Update()
{
CheckNewController();
}
void CheckNewController()
{
Debug.Log("Joy1Start " +Input.GetButton("Joy1Start"));
Debug.Log("Joy2Start "+Input.GetButton("Joy2Start"));
for (var i = 1; i <= MAX_CONTROLLER; i++)
{
if (assignedController.Contains(i))
continue;
if (Input.GetButton("Joy" + i + "Start"))
{
Debug.Log("Add new player on controller" +i);
assignedController.Add(i);
}
}
}
I have my Unity Input setup like this
And a white a black XBOX One controller.
Now, if I put the black controller first then the white, my Debug.Log("Joy2Start ")
fire and the other is always false. no matter which button I press If I do the opposite, and plug the white first, then I have Debug.Log("Joy1Start ")
and same Joy2 stay stay false...
I guess I am doing something wrong, but I can't see :x
Can you enlighten me ?
Thanks
I don't like using Unity's built-in input system when dealing with multiple controllers. It got to me too when I first started. I came across a plugin when I started called XInputDotNet which is for PC and Xbox 360 controllers. I don't see why it wouldn't work for Xbox One as well. Here is a link: https://github.com/speps/XInputDotNet. It's really well done in my opinion. It does actually use Unity's Input System though, but it handles everything for you.
Your answer
Follow this Question
Related Questions
Problems with joystick / controller axes being 1/-1 "way too often" 1 Answer
How do you properly deal with analog joystick input on multiple controller inputs? 1 Answer
Implementing a virtual joystick with mouse 1 Answer
How do I check what input device is currently beeing used? 4 Answers
problems moving game object with the right joystick 1 Answer