- Home /
Question by
neweichgames · May 21, 2020 at 09:59 PM ·
gamepad
Gamepad reconnect issue
I am playing around with the new input system, and I am running into a problem when reconnecting gamepads in game. I am using two playstation controllers and disconnecting controller 1 and then connecting it again. When the controller reconnects, both controllers debug as the second controller. Unity says there is 2 gamepads connected.
Here is my code to test this:
if (Gamepad.all.Count > 0 && Gamepad.all[0].buttonNorth.wasPressedThisFrame)
{
Debug.Log("Controller 1 button press");
}
if (Gamepad.all.Count > 1 && Gamepad.all[1].buttonNorth.wasPressedThisFrame)
{
Debug.Log("Controller 2 button press");
}
Before the reconnection I receive both debug messages. After the reconnection I receive only Controller 2 button press for both controllers. I am not using Player Input or Player Input Manager. I am only using this code. Is there a way to avoid this problem? Should I not be using Gamepad.all to receive input?
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612234927im_/https://answers.unity.com/themes/thub/images/avi.jpg)