The new Input System Package doesn't seem to work with Mirror Networking API

Everytime I spawn 2 players (one host and one client) with the package, the Player Input component on the host looks like this:

It works perfectly fine and reads the inputs from the device. However, the Player Input component on the client looks like this:

Note the missing “Control Scheme” and “Devices” in the “Debug” subcategory, and “Controls(Clone)” instead of “Controls” as “Actions”. The client also doesn’t seem to register any inputs at all.
What should I do for the client to register the same inputs as the host?

2 Likes

This is an annoying issue

I had the problem and i managed to fix it by changing the active input handling to both, you’ll find that in Build Settings > Player Settings > Player > Other Settings > Active input handling.

2 Likes

Is there a solution that doesn’t require changing Active Input Handling? I have the exact same problem as OP but I’d like to use the new input system only.

Hi, I am using the new input system and was facing the same issue now. I solved it like this:
Dont use the editor, create a PlayerInput add the component and load it from Resources.
Create also the InputAction within the script.
Also add the ControlScheme and Action Map manually.
I played around and it seems to work now with this, but I have to check if I have forgotten something, or some stuff is redundant/not necessary. Example for 2 InputActions (Up Keyboard Key and Down Keyboard Key):

  void Start()
  {
    if (isLocalPlayer || isClient)
    {
      PlayerInput playerInput = gameObject.AddComponent<PlayerInput>();
      playerInput.actions = Resources.Load<InputActionAsset>("SimpleControls");
      playerInput.defaultControlScheme = "KeybControlScheme";
      playerInput.defaultActionMap = "SimpleControl";
      playerInput.SwitchCurrentControlScheme("KeybControlScheme");
      playerInput.SwitchCurrentActionMap("SimpleControl");
      playerInput.notificationBehavior = PlayerNotifications.InvokeUnityEvents;

      Down = playerInput.actions["Down"];
      Down.performed += context => OnDownKeyPressed(context);
      Up = playerInput.actions["Up"];
      Up.performed += context => OnUpKeyPressed(context);
      playerInput.onActionTriggered += HandleAction;
      playerInput.ActivateInput();
    }
  }
2 Likes

I am going to try this! :smiley:

Thank you so much, man!!!
This resolved a ton of issues I was having.

Although I set my code up in the StartLocalPlayer method since the PlayeInputScript isn’t need on either the other clients or server. :slight_smile:

Hey, sorry to post so late, but today I was facing the same problem and I think I found an easier and cleaner way to fix it. Instead of creating the whole component through code, I simply disabled the component from the prefab, and enable it when the gameObject is instantiated, using this :

public override void OnStartAuthority()
    {
        base.OnStartAuthority();

        UnityEngine.InputSystem.PlayerInput playerInput = GetComponent<UnityEngine.InputSystem.PlayerInput>();
        playerInput.enabled = true;
    }

With this Mirror method, the component is enabled only for client owning the prefab, and it seemed to resolve the problem entirely. I tested it with host/client + client, and server-only + 3 clients, works fine in every case. I’m using SendMessages() though, not Unity events.
I had to use UnityEnfine.InputSystem.PlayerInput, as writing merely “PlayerInput” was forcing me to use a struct contained in the Unity Class PlayerInputController (weird you guys didn’t seem to have this problem btw, maybe due to my Visual Studio’s preferences, or because of Unity 2020?)

Maybe this will help you or somebody else passing by!

16 Likes

Thanks a ton, man. :smiley:

1 Like

THANKS MAN

This worked for my project. Thanks!

Worked like a charm. Thanks!

Oh my gosh.

I love you.

Thanks a lot man !!!

THANK YOU SO MUCH !!! May you be blessed for the rest of your days

Excellent! Works for me. Thanks!

Another alternative that I used was to simply put my PlayerInput component on a separate local GameObject and populated it in my spawn method whenever the player chose a character. I’m currently using Netcode.

I literally love you. Thank you so much.

Coming from 2024 to thank you worked great in seconds

1 Like