Search Unity

Xbox One controller buttons fire multiple times only when two controllers connected

Discussion in 'Windows' started by nyarsulik, Nov 8, 2018.

  1. nyarsulik

    nyarsulik

    Joined:
    May 7, 2014
    Posts:
    54
    This doesn't happen in the editor, but once I get into Visual Studio and when I deploy to Xbox One this becomes an issue.

    With one controller, everything works great. Once I turn on a second controller, any button press for "Submit" triggers multiple times (even if I try to just tap the button, on the same controller that just worked great a second ago) and then I am unable to open menus without the controller selecting something on the next page automatically.

    This has never been a problem, and I am using essentially the same input setup in Unity that has worked for a few years.

    I posted in the "Help Room" but haven't had a response there. Any help or suggestions would be great. Thanks!
     
  2. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,674
    How are you reading controller input? Does this also happen on the same UWP build on PC?
     
  3. nyarsulik

    nyarsulik

    Joined:
    May 7, 2014
    Posts:
    54
    I don't have a way to post images, but I have my input setup for "Submit" using the positive button "joystick button 0" for the a button on the controller like below:
    • Name: Submit
    • Positive Button: joystick button 0
    • Gravity: 3
    • Dead: 0.001
    • Sensitivity: 3
    • Type: Key or Mouse Button
    • Axis: X axis
    • Joy Num: Get Motion from all Joysticks
    On the UI.Button, I am using the "OnClick" function to call my menu change.

    It is like it is firing on the "press" instead of the release?
     
  4. nyarsulik

    nyarsulik

    Joined:
    May 7, 2014
    Posts:
    54
    In the "Event System" I have it currently set to 5 input actions per second, and a delay of 0.5, but that only seems to help in the editor. It is in VS/PC and Xbox where it triggers like crazy.

    Firing on press isn't horrible, but since it then repeats before I even release it is essentially breaking everything when the second controller is active. It is so strange :)
     
  5. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,674
    Indeed, and if it only happens when 2 controllers are plugged in, could we get a bug report?
     
  6. nyarsulik

    nyarsulik

    Joined:
    May 7, 2014
    Posts:
    54
    Sorry, the Standalone Input Module is also looking for the "Submit" input name for the "Submit Button" action.
     
  7. nyarsulik

    nyarsulik

    Joined:
    May 7, 2014
    Posts:
    54
    Sure. I don't have any real bug output I can show, but I can try to detail the problem like I did here.

    Now, even when only using one controller it still fires on press as opposed to release, is that not something that anyone else has problems with? When I use the mouse, or the keyboard I am able to "hold" the button down and it doesn't trigger until release on those controls.
     
  8. nyarsulik

    nyarsulik

    Joined:
    May 7, 2014
    Posts:
    54
    I take that back, the "Enter/Return" buttons do fire on press, only the mouse does not fire on press.
     
  9. nyarsulik

    nyarsulik

    Joined:
    May 7, 2014
    Posts:
    54
    Last edited: Nov 8, 2018
  10. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,674
    Don't you have an example showing that the button is triggered multiple times from a single press?
     
  11. nyarsulik

    nyarsulik

    Joined:
    May 7, 2014
    Posts:
    54
    I can try to screen record. However, it looks like I don't have a way to post a bug regardless. Perhaps that is reserved for Pro users only?
     
  12. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,674
  13. nyarsulik

    nyarsulik

    Joined:
    May 7, 2014
    Posts:
    54
    Ok, bug report submitted with video of the issue while in VS and then a few screenshots of my Input setup and one of the UI.Button items in the editor, just to make sure it isn't something I am doing accidentally.

    Case 1099111

    Thanks again for your help!
     
  14. nyarsulik

    nyarsulik

    Joined:
    May 7, 2014
    Posts:
    54
    Tautvydas-Zilys, do you know if anyone else has had this issue? I still can't figure out what is happening here, but did submit the bug report.
     

    Attached Files:

  15. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,674
    I've not heard about it before, no. Our QA should get back to you shortly and look at it.
     
  16. bphillips09

    bphillips09

    Joined:
    Aug 31, 2014
    Posts:
    36
  17. PixelSunsetStudio

    PixelSunsetStudio

    Joined:
    Dec 10, 2013
    Posts:
    11
    I'm having the same issue, using the latest Unity 2018.3.1f1.

    If I have only one controller plugged in, I have no issues. But if there are two or more controllers connected, the buttons are firing (just like a GetButton() instead of a GetButtonDown())

    Did you found a way to fix this ?
    It's very annoying for my menus on my local-multiplayer game coming on XBox...
     
  18. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,674
    Could you also file a bug report with a repro project? QA had issues reproducing the issue.
     
  19. PixelSunsetStudio

    PixelSunsetStudio

    Joined:
    Dec 10, 2013
    Posts:
    11
    Here is what I've done :

    I have created a brand new project in Unity.
    I added in the scene an Image and a button.

    I created a script that I attached to an empty game object in the scene, with the following code
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.UI;
    5.  
    6. public class UIManager : MonoBehaviour
    7. {
    8.    public void ToggleImage(Transform image)
    9.     {
    10.         image.gameObject.SetActive(!image.gameObject.activeInHierarchy);
    11.     }
    12. }
    On the button, in the OnClick() parameter, I've added the game object with the script and selected the ToggleImage with the image transform.

    On the EventSystem, I have set the "First Selected" variable to be the button, and I checked "Force Module Active" in the Standalone Input Module.

    In the Editor, everything works fine, meaning anytime I press the button, the image is toggle on or off and nothing more happens if I keep the button hold.

    If I export my game on my XBox, then the issue arise.
    If I have only one controller plugged, everything works fine. But if I plug a second controller, then when I press my submit button, the image starts flickering, toggling on and off repeatedly.


    I didn't really new what you needed and how to give you what you need, so I created a .rar with everything in (Unity Project, UWP VS Solution and Exported Packages in Release x64) that I have uploaded on my own FTP.

    You can download the .rar file here: http://www.pixelsunsetstudio.com/ControllerBugUWP/ControllerBugUWP.rar
     
  20. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,674
    Okay, I'll ping our QA and ask them to reproduce it again.
     
  21. PixelSunsetStudio

    PixelSunsetStudio

    Joined:
    Dec 10, 2013
    Posts:
    11
    Great :)

    Hope you have what you need to be able to help us ^^
     
  22. nyarsulik

    nyarsulik

    Joined:
    May 7, 2014
    Posts:
    54
    I never found a fix... The bug report asked me to provide a build (but I have not been able to do that yet). This is actually affecting the games I already have on the Xbox store! :| I guess that means I don't have a lot of people actually playing local multiplayer at the moment, or they just stopped playing and haven't seen the issue.
     
  23. nyarsulik

    nyarsulik

    Joined:
    May 7, 2014
    Posts:
    54
    Just to note, I think I did see this also when testing in Visual Studio, not just on Xbox. But, like you mention, I do not see this in the Unity Editor.
     
  24. PixelSunsetStudio

    PixelSunsetStudio

    Joined:
    Dec 10, 2013
    Posts:
    11
    Are there any news about this issue?

    Do QA have what they need to investigate?
    Were they able to reproduce the bug whith the files I uploaded?
     
  25. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,674
    We reproduced it. It has now been forwarded to our dev team to investigate.
     
  26. timke

    timke

    Joined:
    Nov 30, 2017
    Posts:
    407
    I've identified the problem and working on a fix for the bug.

    The problem is with the "global" keystate, i.e. Joystick 0, in which the "pressed" state is set from any/all connected controllers, joysticks, or gamepads. Since the Button's OnClick event accepts input from any source, it's reading from Joystick 0 state.

    In UWP, when 2 controllers are connected, the first on "sets" the global state when the button is pressed but then the second gamepad "resets" the state because it's button isn't pressed. This flip/flopping causes OnClick's event to fire every frame.

    Unfortunately, the only work-around (until the fix is released) is to directly read input from a specific controller (not Joystick 0) and then manually invoke OnClick.
     
  27. madcowie

    madcowie

    Joined:
    Aug 11, 2014
    Posts:
    20
    Any further updates with this issue? My game does the same when 2 controllers are turned on! Its like rapid fire on the UI buttons! In game works fine but that doesnt use UI buttons. This project is still in Unity 2018.2 I may add. Scared to upgrade it! :)
     
  28. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,674
    It was fixed in one of the 2018.3.x patches.
     
    nyarsulik likes this.
  29. madcowie

    madcowie

    Joined:
    Aug 11, 2014
    Posts:
    20
    Thanks for the reply. Hope my project bloody imports to the new version okay then! Scared!
     
  30. nyarsulik

    nyarsulik

    Joined:
    May 7, 2014
    Posts:
    54
    I am in the middle of converting a lot of code to C# and will have to try this once I get my game all upgraded correctly. I wish it at least would show the old JS script names in the inspector, it has been a pain trying to remember which scripts I had been using on some items. Do we still need to do the work around or will this fix the issue even if we are still referencing joystick 0? Thanks!
     
  31. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,674
    You shouldn't need the workaround anymore.
     
  32. Translunary

    Translunary

    Joined:
    Sep 9, 2019
    Posts:
    2
    How do you read controller input?
     
  33. Ascanio1980

    Ascanio1980

    Joined:
    Jun 7, 2019
    Posts:
    51
    I am having this issue in Unity 2020.1.1f1 when running on iOS (14) with a PS4 Dual Shock controller. Tried Input.GetKey() Input.GetKeyDown() and Input.GetKeyUp(). They just get fired every frame while the button is pressed.

    Is there any way to read controller input directly? And is there a more efficient way than just leaving the code in Update()... like adding some listeners for the specific events?