Unity-Technologies / com.unity.netcode.gameobjects

Netcode for GameObjects is a high-level netcode SDK that provides networking capabilities to GameObject/MonoBehaviour workflows within Unity and sits on top of underlying transport layer.
MIT License
2.09k stars 430 forks source link

Wrong client ID passed to NetworkManager.OnClientDisconnectCallback #2799

Closed JoshJarc closed 6 months ago

JoshJarc commented 6 months ago

Description

When the host/client disconnects from the game server, the ID passed to NetworkManager.OnClientDisconnectedCallback on that Host/client is incorrect. When that same host/client connects using NetworkManager.OnClientConnectedCallback the id is correct and doesn't match the id when NetworkManager.OnClientDisconnectedCallback is called. If the client is not host everything works and ids are correct. Just the host/client has this issue. Screenshot below

Reproduce Steps

  1. In code, provide a callback function for NetworkManager.Singleton.OnClientDisconnectedCallback on the client.
  2. In that callback function, print to the console the values for the function parameter and NetworkManager.Singleton.LocalClientId
  3. Start a server using NetworkManager.StartHost()
  4. Note the id passed in NetworkManager.Singleton.OnClientConnectedCallback
  5. Start a client using StartClient()
  6. After both are connected, disconnect the host.
  7. Observe the console log on the Host/client and note that the two values are different.

Actual Outcome

When the host disconnects the client id passed is incorrect. It doesn't match the client id passed when the host/client connects using OnClientConnectedCallback.

Expected Outcome

The client id passed in OnClientConnectedCallback should match the value passed in OnClientDisconnectedCallback.

Screenshots

image

Environment

NoelStephensUnity commented 6 months ago

Hi Josh,

This issue was resolved in PR-2789 and will be included in the soon to be released v1.8.0 update.