Search Unity

Player Input Manager logs redundant error on player join when max players reached

Discussion in 'Input System' started by SudoCat, Jun 24, 2021.

  1. SudoCat

    SudoCat

    Joined:
    Feb 19, 2013
    Posts:
    64
    I'm using the Player Input Manager to quickly get starting with multiplayer input for a player join screen. Overall, it works like a charm and has saved a lot of time to get the prototype working.

    However, the Max Player Count functionality behaves particularly strangely.

    When Join Behaviour is set to use a Join Action, the Player Input Manager is logging a "Have reached maximum player count" in the console every type the join action is pressed on a controller which has already been paired. This is a real nuisance, as it means that when the maximum number of players have connected their controllers, every press of the submit action logs another error into the console.

    The source of the error is the JoinPlayerFromActionIfNotAlreadyJoined method. You would think that, based on the name, this method should not log an error if the player has already joined. Yet due to the order it checks in, it constantly logs redundant errors. I feel this should check if the player has joined before hand, to avoid redundant errors.

    upload_2021-6-24_18-22-7.png

    For now, I'm just going to attempt manually disabling/re-enabling the player join behaviour when max players reached, but it would be nice if this could be resolved, so standard usage doesn't logmisleading errors.

    This doesn't even really seem like it should warrant a LogError - nothing has errored, it's behaving as expected. Absolute worst I'd consider is a LogWarning.
     
    SlowSeer likes this.
  2. SlowSeer

    SlowSeer

    Joined:
    Jun 2, 2015
    Posts:
    3
    Still happening in the most recent 2021 LTS. I took your advice and made a function like this that I call from both
    OnPlayerJoined
    and
    OnPlayerLeft
    .

    Code (CSharp):
    1.  
    2. if (players.Count >= playerInputManager.maxPlayerCount && playerInputManager.joiningEnabled)
    3.     playerInputManager.DisableJoining();
    4. else if (players.Count < playerInputManager.maxPlayerCount && !playerInputManager.joiningEnabled)
    5.     playerInputManager.EnableJoining();
    6.  
     
    EDevJogos and Bakakami like this.