Search Unity

Input System + Netcode issues

Discussion in 'Multiplayer' started by MikeOStreamline, Jan 4, 2023.

  1. MikeOStreamline

    MikeOStreamline

    Joined:
    Nov 3, 2022
    Posts:
    4
    Are there any known issues regarding the new(ish) Input System and synching objects with Netcode?

    I was following an officially sponsored Unity video by Terodev using Netcode and it worked out great. However, in order to spice things up at work I decided to work with the new(ish) Input System (ver 1.4.4) and the Jammo character from the Asset store. I followed another tutorial from iLoveGameDev and had the new input system working fine.

    However, when I tried to re-do the Terodev tutorial with the new character instead of the simple capsule things fell apart quickly. For example, the ClientNetworkTransform wasn't working at all and nothing was synching.
    (There was also strange behavior like, for example, during most tutorials at some point you control both characters on each instance and it's not synched up, etc. But even before I realized CNT was broken I noticed that even though I'd move the host to another spot before spawning the client, the host would NOT be in the correct position. I was also only controlling one character, etc)

    So it seems like there's an issue and I know I can go back to another system but I spent a lot of time learning the new stuff and would much prefer to have that than the old stuff.

    Thanks!
    -Mike
     
    barisdincer likes this.
  2. RikuTheFuffs-U

    RikuTheFuffs-U

    Unity Technologies

    Joined:
    Feb 20, 2020
    Posts:
    440
    Hi @MikeOStreamline , from what you have describing I have the felling that the script that manages your playerInput is enabled by default on your player prefabs.

    Have you already had a look at the examples in the official ClientDriven sample?

    If not, you can download it here
     
  3. MikeOStreamline

    MikeOStreamline

    Joined:
    Nov 3, 2022
    Posts:
    4
    Thank you for the response and that project. It's very interesting and I can see the components that are turned on during startup and sure enough there were synched transform/animation action happening when running.

    However, I noticed that the Bitesize project uses a PlayerInput that's added via the "Add Component" button and is an extension of MonoBehavior. Also, the asset in /InputSystem does not have the "Generate C# Class" button checked.

    My PlayerInput asset has that checked so it creates a PlayerInput.cs C# file where the PlayerInput class is defined like this:

    public partial class @PlayerInput : IInputActionCollection2, IDisposable

    I didn't realize there were more than one kind of PlayerInput and so far all my experiments with shutting off components and turning them on at runtime in my version not only doesn't work but seems to kill the player controls altogether. Is there something about the generated C# class version of PlayerInput that needs to be handled differently? Or perhaps I should use the Bitesize demo way instead?

    Thank you again
    -Mike
     
  4. chemicalcrux

    chemicalcrux

    Joined:
    Mar 16, 2017
    Posts:
    720
    The name of the generated file is based on the name of the input action asset. So, if you named yours "PlayerInput", you'd wind up with a file with that name. Hence the confusion.

    You'd want to go with the provided PlayerInput component.
     
  5. MikeOStreamline

    MikeOStreamline

    Joined:
    Nov 3, 2022
    Posts:
    4
    Ok thank you to you both I have an update. It turns out that NOT generating the .cs file at all is part of the core of the solution. Instead of generating that, creating an instance and adding calls manually you add the PlayerInput component the usual way and set it up. If you manage to handle the components that need to be shut on and off properly and do things that way the CharacterControllers sync up beautiflly. That Client example really helped.
    Thanks again!
    -Mike
     
    koskertarik and RikuTheFuffs-U like this.
  6. Davidjsap

    Davidjsap

    Joined:
    Aug 17, 2017
    Posts:
    11
    I am completely stumped by this - reading the ClientDriven didn't help me; when I use Keyboard&Mouse with the new input system, everything works fine, yet using the Gamepad version of those actions and all players on the network are controlled by the controller simulatenously.

    I'm just using a very basic implementation of the given PlayerInput class with Move and Jump actions. Regardless of anything else, I can't for the life of me figure out why Keyboard&Mouse is being treated differently (and working conrrectly) compared to gamepad. They resulting values are treated the same everywhere in my code, so I can't understand why they would perform differently.

    Any help would be appreciated! @RikuTheFuffs-U
     
  7. jujorie_unity

    jujorie_unity

    Joined:
    Aug 29, 2022
    Posts:
    1
    I had the same problem and in my case was fixed disabling the PlayerInput component on the _
    OnNetworkSpawn_ method. I'm not sure why, but that was the only way to make a cliet move using the InputSystem.
     
    ANGELBEAR24 likes this.
  8. ANGELBEAR24

    ANGELBEAR24

    Joined:
    Apr 10, 2020
    Posts:
    2
    You disabled it for just the clients or the host as well? Did you turn it back on later in your script or just leave it off?

    Thank you for the explanation. I’m been beating my head against the desk over this same issue