[Multiplayer Play Mode] Error when connecting from/to Virtual Player after editing networked prefab

Bug: after editing networked prefab attempting to connect from/to virtual player throws error:

[Netcode] NetworkConfig mismatch. The configuration between the server and client does not match

Creating reproducible exampe shows that something fishy is going on with sync to virtual player after prefab editing.
Observable side effect - “GlobalObjectIdHash” changes in virtual player.

Restarting virtual player fixes issue until next edit of networked prefab.

Versions:

  • Editor: 6000.0.29f1
  • com.unity.netcode.gameobjects: 2.1.1
  • com.unity.multiplayer.playmode: 1.3.2

System:
OS: Windows 11 (10.0.22631) 64bit
CPU: Intel(R) Core™ i7-14700KF, 28
Physical RAM: 32581 MB

Short overview on how to reproduce:

  1. Install NGO and Play mode packages
  2. Configure default network manager & transport
  3. Create Player prefab with default network object component
  4. Enable Virtual Player 1
  5. First play session - start host in virtual player, connect from main editor
  6. Edit player prefab (e.g. change sprite color)
  7. Second play session - start host in virtual player, attempt connect from main editor
  8. Get error

Detailed steps on how to reproduce:

(1) Create project & install packages

1.1 Create new project - Universal 2D
1.2 Window → Package Manager
Install:
com.unity.netcode.gameobjects
com.unity.multiplayer.playmode
1.3 Open SampleScene

(2) Configure Network Manager

2.1 Create new GameObject
2.2 Rename to “NetworkManager”
2.3 Add “Network Manager” component
2.4 Select “Unity Transport”

(3) Create Player prefab

3.1 Create new square sprite (2D Object → Sprites → Square)
3.2 Rename to “Player”
3.3 Add Network Object component
3.4 Save as “Player” prefab
3.5 Remove from scene
3.6 Set “Player” prefab as “Default Player Prefab” in Network Manager

(4) Configure virtual player

4.1 Open Window → Multiplayer → Multiplayer Play Mode
4.2 Activate “Player 2” virtual player

(5) First play session (everything works)

5.1 Enter play mode
5.2 [Virtual Player 1] Focus NetworkManager
5.3 [Virtual Player 1] Press “Start Host”
5.4 [Virtual Player 1] Focus instantiated player object and write down “GlobalObjectIdHash”
For me it was: “3475022634”
5.5 [Main Editor] Focus NetworkManager
5.6 [Main Editor] Press “Start Client”
5.7 [Main Editor] Focus instantiated player objects (2) and write down “GlobalObjectIdHash”
For me it was: “3475022634” (both objects)
5.8 Stop play mode

(6) Edit prefab

6.1 Open “Player” prefab
6.2 Change sprite color to any other color

(7) Second play session (where it breaks)

7.1 Enter play mode
7.2 [Virtual Player 1] Focus NetworkManager
7.3 [Virtual Player 1] Press “Start Host”
7.4 [Virtual Player 1] Focus instantiated player object and write down “GlobalObjectIdHash”
For me it was: “3871928766” (note: different from first play session)
7.5 [Main Editor] Focus NetworkManager
7.6 [Main Editor] Press “Start Client”
We get error in [Virtual Player 1]:

[Netcode] NetworkConfig mismatch. The configuration between the server and client does not match
UnityEngine.Debug:LogWarning (object)
Unity.Netcode.NetworkLog:LogWarning (string) (at ./Library/PackageCache/com.unity.netcode.gameobjects/Runtime/Logging/NetworkLog.cs:28)
Unity.Netcode.ConnectionRequestMessage:Deserialize (Unity.Netcode.FastBufferReader,Unity.Netcode.NetworkContext&,int) (at ./Library/PackageCache/com.unity.netcode.gameobjects/Runtime/Messaging/Messages/ConnectionRequestMessage.cs:169)
Unity.Netcode.NetworkMessageManager:ReceiveMessage<Unity.Netcode.ConnectionRequestMessage> (Unity.Netcode.FastBufferReader,Unity.Netcode.NetworkContext&,Unity.Netcode.NetworkMessageManager) (at ./Library/PackageCache/com.unity.netcode.gameobjects/Runtime/Messaging/NetworkMessageManager.cs:578)
Unity.Netcode.NetworkMessageManager:HandleMessage (Unity.Netcode.NetworkMessageHeader&,Unity.Netcode.FastBufferReader,ulong,single,int) (at ./Library/PackageCache/com.unity.netcode.gameobjects/Runtime/Messaging/NetworkMessageManager.cs:444)
Unity.Netcode.NetworkMessageManager:ProcessIncomingMessageQueue () (at ./Library/PackageCache/com.unity.netcode.gameobjects/Runtime/Messaging/NetworkMessageManager.cs:470)
Unity.Netcode.NetworkManager:NetworkUpdate (Unity.Netcode.NetworkUpdateStage) (at ./Library/PackageCache/com.unity.netcode.gameobjects/Runtime/Core/NetworkManager.cs:300)
Unity.Netcode.NetworkUpdateLoop:RunNetworkUpdateStage (Unity.Netcode.NetworkUpdateStage) (at ./Library/PackageCache/com.unity.netcode.gameobjects/Runtime/Core/NetworkUpdateLoop.cs:191)
Unity.Netcode.NetworkUpdateLoop/NetworkEarlyUpdate/<>c:<CreateLoopSystem>b__0_0 () (at ./Library/PackageCache/com.unity.netcode.gameobjects/Runtime/Core/NetworkUpdateLoop.cs:214)

7.7 Stop play mode

(8) Third play session (host in main editor)

8.1 Enter play mode
8.2 [Main Editor] Focus NetworkManager
8.3 [Main Editor] Press “Start Host”
8.4 [Main Editor] Focus instantiated player object and write down “GlobalObjectIdHash”
For me it was: “3475022634” (same as in first play session)

4 Likes

Earlier thread about similar (same?) issue: Multiplayer Playmode doesn't survive changes with Netcode for Gameobjects

I have this issue as well, both in Parrelsync (no matter the version) as well as MPM. I wonder if Unity partner with parrelsync and used their code for this implementation? The UI looks different, but it seems to behave similar. I was excited to use MPM and avoid this exact issue, but it seems like it’s still there.

I see the recommendation to try creating your own prefab list instead of using the default one. Restarting the virtual player sometimes works and sometimes doesn’t. Sometimes editing prefabs doesn’t cause the issue. To me it sounds like the prefab list isn’t getting transferred to the virtual player properly. Let me know if creating your own prefab list fixes it, I can’t test it right now. I have the same CPU and RAM as you, not sure about my windows version though.

I have managed to narrow down exact scenario when bug occurs.

Created new Github issue: GlobalObjectIdHash contains invalid if networked prefab was edited from Prefab mode · Issue #3151 · Unity-Technologies/com.unity.netcode.gameobjects · GitHub

It is similar to last year issue (that was fixed previously): NetworkObject.GlobalObjectIdHash serializes invalid values when in Prefab Mode · Issue #2653 · Unity-Technologies/com.unity.netcode.gameobjects · GitHub

Check my new Github issue for details.

TLDR: Virtual player read incorrect configuration if prefab was last edited from “prefab mode”

Workaround: Do any change to a Networked Prefab from “regular mode” (toggling on/off any checkbox works). This makes Virtual Player to read correct object id hash.

1 Like

I occassionally run into these too.

Try running File => Save Project after step 6 before starting the next play session. It may also suffice to press Ctrl+S with the prefab open, or closing the prefab (exit prefab edit mode if you use that to make the change).

You should send this as a bug report via Help => Bug Report to make sure this doesn’t go unnoticed.

1 Like

NGO v2.2.0 should include PR-3162 which should resolve any issues that were occurring during the GlobalObjectIdHash generation if entering into play mode while still in prefab edit mode (either the asset directly or via in-scene placed).

After updating to this version if you still see issues please let me know.

1 Like