Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Bug Multiplayer Playmode doesn't survive changes with Netcode for Gameobjects

Discussion in 'Multiplayer Tools' started by Yoraiz0r, Aug 3, 2023.

  1. Yoraiz0r

    Yoraiz0r

    Joined:
    Apr 26, 2015
    Posts:
    78
    Using MPPM 0.2.0 on Unity 2023.1.3f1, with Netcode for Gameobjects 1.5.1, I encountered a situation that demands I restart my MPPM instances... and that wouldn't be a problem - except this situation is extremely common.

    All I had to do to trigger this situation, is to add a network transform component to my 'player' netcode gameobject.

    Any attempt to enter a playmode session connection after that, results in "[Netcode] NetworkConfig mismatch. The configuration between the server and client does not match".

    I tried to dig deeper and it seems the network manager component in the scene has a
    NetworkConfig that compares some hash. However, I have reasons to believe this hash somehow doesn't get updated on the virtual players made by MPPM despite attempting to save the scene / reopening it.

    I also confirmed other changes do pass to the virtual players - such as changing the floor material's color. It is only this weird hash of Netcode for Gameobjects that fails to transfer.

    I also confirmed this happens regardless of whether domain reload is enabled or disabled, which leads me to believe this is some serialized state that is not set to dirty within Netcode for Gameobjects, but I could be wrong?

    How can I fix this so the MPPM experience can be smooth and without constant restarts any time I add or change a single component to my networked game using NGO?

    Edit: I added a call to NGO's NetworkManager.NetworkConfig.GetConfig() and the result seems to point to the hash on the virtual players changing when the networktransform is added... but the main player's hash does not. I don't know what to make of this, still investigating how this hash is constructed, a lot of things in it seem rather deterministic and cacheless?

    Edit2: It appears that "Force same prefabs" fails makes this fail, and even with it off - there seems to be some prefab mismatch for the virtual player versus the main player. If I disable "force same prefabs" and additionally make a prefab list with manual hash number for the player prefab, the issue goes away - though this is far from comfortable or sustainable, and feels like it shouldn't be an issue in the first place? I still don't know what in MPPM causes this disparity.

    Edit3: I may be wrong but I think I traced this to NetworkObject.GenerateGlobalObjectIdHash returning different hashes between the two players.
     
    Last edited: Aug 4, 2023
    saskenergy and RicherNicholas like this.
  2. Yoraiz0r

    Yoraiz0r

    Joined:
    Apr 26, 2015
    Posts:
    78
    After more investigation, I believe this issue has nothing to do with MPPM. It is directly related to Netcode for Gameobjects alone.
    NetworkObject.GenerateGlobalObjectIdHash
    generates invalid hashes for gameobjects and prefabs under certain conditions (either in a not-yet-saved scene, or a prefab saved in prefab mode's scene), and never updates the written-to-disk values afterwards, with direct values changing.

    Because the editor will update the running memory value to a valid one once you leave prefab mode, but the disk value is invalid, the virtual players and the primary editor are mismatched. Not MPPM's fault, but the discrepency is frustrating.

    I've opened an issue for this on the Netcode for Gameobjects github repository, hopefully this can be soon fixed for everyone.
     
  3. simon-lemay-unity

    simon-lemay-unity

    Unity Technologies

    Joined:
    Jul 19, 2021
    Posts:
    416
    Thanks for the detailed write-up! We really appreciate you going above and beyond to investigate this issue.

    I've brought your ticket to the attention of the NGO team. It does seem to be a very annoying issue when working with NGO and MPPM together. Do you know if the same problem occurs if using ParrelSync?
     
    Yoraiz0r likes this.
  4. Yoraiz0r

    Yoraiz0r

    Joined:
    Apr 26, 2015
    Posts:
    78
    I have not verified it, but I have verified that the issue is related to NGO itself and MPPM is not at fault at all. I'd like to say there is nothing for MPPM to fix. I pulled NGO and made a fix for myself, which I've posted on the repository's issue above.

    And thank you for the follow ups!
     
  5. NoelStephens_Unity

    NoelStephens_Unity

    Unity Technologies

    Joined:
    Feb 12, 2022
    Posts:
    244
    The issue was specific to GlobalObjectIdHash generation and PR-2662 should resolve this issue with MPPM and Parrel Sync. This fix will be the next update (after v1.6.0).
     
    Yoraiz0r likes this.