Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only.

    Please, do not make any changes to your username or email addresses at id.unity.com during this transition time.

    It's still possible to reply to existing private message conversations during the migration, but any new replies you post will be missing after the main migration is complete. We'll do our best to migrate these messages in a follow-up step.

    On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live.


    Read our full announcement for more information and let us know if you have any questions.

Bug Local Multiplayer - Players after Player 1 Cannot Control UI Navigation

Discussion in 'Input System' started by cnjodlowski, May 24, 2023.

  1. cnjodlowski

    cnjodlowski

    Joined:
    Apr 13, 2019
    Posts:
    2
    Hi all,

    I'm running into an issue where navigation for the new input system and local multiplayer. After some testing - I realized that UI inputs that were not from Player 1 - the first player spawned in the scene - would not be registered.

    Whether the players are on Mouse/Keyboard or Controller does not seem to affect this.


    upload_2023-5-24_11-28-51.png
    This is the current PlayerInput I have on my player prefab.

    upload_2023-5-24_11-30-2.png
    I copied the default UI Action Map onto my custom Input Action Asset - as I didn't want to redo all of the custom controls I have setup.

    upload_2023-5-24_12-16-57.png
    UI Module on the Event System

    The only code I currently have setup that involves switching action maps is for the Pause Menu
    Code (CSharp):
    1.     public void Pause(int playerID, bool isPausing)
    2.     {
    3.      
    4.      
    5.         if(isPausing)
    6.         {
    7.             isPaused = true;
    8.             pausedPlayerId = playerID;
    9.             Time.timeScale = 0;
    10.  
    11.             Debug.Log(" ^^ Player " + playerID + " Paused");
    12.  
    13.             foreach(Player p in players)
    14.             {
    15.                 if(p.id != playerID)
    16.                 {
    17.                     //p.playerInput.DeactivateInput();
    18.                     Debug.Log(" ^^ Player " + p.id + " Deactivated");
    19.                 } else
    20.                 {
    21.                     p.playerInput.SwitchCurrentActionMap("Menuplay");
    22.                        Debug.Log(" ^^ Player " + p.id + " Controlling Input");
    23.                     Debug.Log("Player is using " + p.playerInput.currentControlScheme);
    24.                  
    25.                 }
    26.             }
    27.         } else
    28.         {
    29.             isPaused = false;
    30.             pausedPlayerId = -1;
    31.             Time.timeScale = 1;
    32.  
    33.             foreach (Player p in players)
    34.             {
    35.                 if (p.id != playerID)
    36.                 {
    37.                     //p.playerInput.ActivateInput();
    38.                     Debug.Log(" ^^ Player " + p.id + " Reactivated");
    39.                 }
    40.                 else
    41.                 {
    42.                     p.playerInput.SwitchCurrentActionMap("Gameplay");
    43.                     Debug.Log(" ^^ Player " + p.id + " Switched back to Gameplay");
    44.                 }
    45.             }
    46.         }
    47.         pauseMenu.SetActive(isPaused);
    48.     }
    When implementing code for the Menus- my original idea was to deactivate input from all other players except for who paused, but even with code commented out I am running into the same issue.

    I'm still fairly new to using the Player Input Manager in regards to the rest of the new input system - so if there's any other info needed I will happily provide.

    Thanks all
     
  2. cnjodlowski

    cnjodlowski

    Joined:
    Apr 13, 2019
    Posts:
    2
    Got it. Had to set the UI Input Actions in code.
    Code (CSharp):
    1. //In OnStart
    2. inputSystemUIInputModule = GameObject.FindGameObjectWithTag("EventSystem").GetComponent<InputSystemUIInputModule>();
    3.  
    4. //In Pause Function
    5. inputSystemUIInputModule.actionsAsset = p.playerInput.actions;