Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Bug NetworkManager.Singleton.IsClient is TRUE on dedicated server

Discussion in 'Netcode for GameObjects' started by UnkelRambo, Dec 22, 2022.

  1. UnkelRambo

    UnkelRambo

    Joined:
    Oct 26, 2012
    Posts:
    80
    OK I'm not sure HOW I haven't noticed this before, but I just ran into a nasty issue where NetworkManager.Singleton.IsClient is TRUE on dedicated server builds.

    I just HAPPEN to have a decent workaround for this that fixes just about every issue I'll have as a result, but I was curious if anybody else has tested a Dedicated Server build? I'm not sure what I could've done on my end for this to be messed up but I wouldn't put it past me ;)
     
  2. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    6,467
    Is this maybe before the server got started, or called too early before NetworkManager is initialized? Maybe the dedicated server build is actually running StartClient() instead?

    You may want to make a simple test with a new project to confirm whether the issue is reproducible if you can't find a flaw in your code. When an issue like this seems as fundamental as you describe it, I find it likely it is already known with users complaining but I'm not aware of any of that. I would first check the more likely causes (see above).

    That's not to say it cannot be a bug, just doesn't seem very likely. ;)
    Btw, which version of Netcode? Maybe try upgrade to the latest (v1.2) if you aren't using that.
     
  3. cerestorm

    cerestorm

    Joined:
    Apr 16, 2020
    Posts:
    674
    I just tested this and it's coming up as false for me. I don't check this flag though but use SystemInfo.graphicsDeviceType == UnityEngine.Rendering.GraphicsDeviceType.Null to check it's the server in the bootstrap code. The bootstrap code itself is a cut down version of the Multiplay example.
     
  4. RikuTheFuffs-U

    RikuTheFuffs-U

    Unity Technologies

    Joined:
    Feb 20, 2020
    Posts:
    440
    This will work only when running the server in batchmode thoug, unless the dedicated server build forces the graphic device to null
     
  5. cerestorm

    cerestorm

    Joined:
    Apr 16, 2020
    Posts:
    674
    I'm not using batchmode or any server command line arguments outside of my own, should I be? (this is in Unity 2020)