Skip to content

Commit f6d3a58

Browse files
fix: NetworkManager not returning correct LocalClientId on server side (#2398)
* fix The NGO ServerClientId should be assigned when starting the server and should be used to return the correct LocalClientId (NGO Layer) on the server or host side.
1 parent 3d2c266 commit f6d3a58

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

com.unity.netcode.gameobjects/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ Additional documentation and release notes are available at [Multiplayer Documen
2121
- Network prefabs are now stored in a ScriptableObject that can be shared between NetworkManagers, and have been exposed for public access. By default, a Default Prefabs List is created that contains all NetworkObject prefabs in the project, and new NetworkManagers will default to using that unless that option is turned off in the Netcode for GameObjects settings. Existing NetworkManagers will maintain their existing lists, which can be migrated to the new format via a button in their inspector. (#2322)
2222

2323
### Fixed
24+
- Fixed issue where `NetworkManager.LocalClientId` was returning the `NetworkTransport.ServerClientId` as opposed to the `NetworkManager.m_LocalClientId`. (#2398)
2425
- Fixed a UTP test that was failing when you install Unity Transport package 2.0.0 or newer. (#2347)
2526
- Fixed issue where `NetcodeSettingsProvider` would throw an exception in Unity 2020.3.x versions. (#2345)
2627
- Fixed server side issue where, depending upon component ordering, some NetworkBehaviour components might not have their OnNetworkDespawn method invoked if the client side disconnected. (#2323)

com.unity.netcode.gameobjects/Runtime/Core/NetworkManager.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ public GameObject GetNetworkPrefabOverride(GameObject gameObject)
283283
/// </summary>
284284
public ulong LocalClientId
285285
{
286-
get => IsServer ? NetworkConfig.NetworkTransport.ServerClientId : m_LocalClientId;
286+
get => m_LocalClientId;
287287
internal set => m_LocalClientId = value;
288288
}
289289

@@ -802,6 +802,7 @@ public bool StartServer()
802802
IsServer = true;
803803
IsClient = false;
804804
IsListening = true;
805+
LocalClientId = ServerClientId;
805806

806807
try
807808
{

0 commit comments

Comments
 (0)