Search Unity

Feature Request I wasted two days fixing a bug because Unity doesn't log when it starts local multiplayer mode.

Discussion in 'Input System' started by John_Leorid, Jan 7, 2023.

  1. John_Leorid

    John_Leorid

    Joined:
    Nov 5, 2012
    Posts:
    651
    When you have two playerinputs in your Hierarchy, the InputSystem (PlayerInput-Component) will globally deactivate one InputDevice for the InputActionAsset (and its Sub-Assets).

    In my case, I have two scenes:
    LevelScene (contains enemies, houses, environment) and PlayerScene (contains the Player and UI)

    I wanted to be sure that there is an PlayerInput somewhere, so I had a script, registered to "onSceneLoaded" which will generate a PlayerInput when none is found. Because PlayerInput seems to be neccessary to get the DeviceChanged event, and I need to know when that happens because of my WeaponWheel which will act differently, whether it's used with Mouse or Controller.

    So what happend:
    1) I loaded the level scene
    2) onSceneLoaded was executed
    3) No PlayerInput was found by my Script so a new one was created
    4) Now the PlayerScene was loaded (with its PlayerInput-Component)
    5) Now I had two PlayerInput-Components in my hierarchy
    6) PlayerInput detects this as local multiplayer and assigns one device to the second PlayerInput, and deactivates it globally
    - but I don't have any local multiplayer in my game, for me the controller just stopped working.

    And there we need a Debug.Log "Local Multiplayer Setup Detected".
    With this log, the whole fix would have taken me less than 10 minutes. Instead of two entire days of bugfixing.

    So please, add a log when that happens.