Description
When the host disconnects and a certain object is not owned by the server, the following NullReferenceException is thrown:
NullReferenceException: Object reference not set to an instance of an object
Unity.Netcode.NetworkVariableBase.SetDirty (System.Boolean isDirty) (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.6.0/Runtime/NetworkVariable/NetworkVariableBase.cs:98)
Unity.Netcode.NetworkBehaviour.MarkVariablesDirty (System.Boolean dirty) (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.6.0/Runtime/Core/NetworkBehaviour.cs:730)
Unity.Netcode.NetworkObject.MarkVariablesDirty (System.Boolean dirty) (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.6.0/Runtime/Core/NetworkObject.cs:1127)
Unity.Netcode.NetworkSpawnManager.ChangeOwnership (Unity.Netcode.NetworkObject networkObject, System.UInt64 clientId) (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.6.0/Runtime/Spawning/NetworkSpawnManager.cs:266)
Unity.Netcode.NetworkSpawnManager.RemoveOwnership (Unity.Netcode.NetworkObject networkObject) (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.6.0/Runtime/Spawning/NetworkSpawnManager.cs:245)
Unity.Netcode.NetworkObject.RemoveOwnership () (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.6.0/Runtime/Core/NetworkObject.cs:640)
Unity.Netcode.NetworkConnectionManager.OnClientDisconnectFromServer (System.UInt64 clientId) (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.6.0/Runtime/Connection/NetworkConnectionManager.cs:821)
Unity.Netcode.NetworkConnectionManager.DisconnectRemoteClient (System.UInt64 clientId) (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.6.0/Runtime/Connection/NetworkConnectionManager.cs:877)
Unity.Netcode.NetworkConnectionManager.Shutdown () (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.6.0/Runtime/Connection/NetworkConnectionManager.cs:976)
Unity.Netcode.NetworkManager.ShutdownInternal () (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.6.0/Runtime/Core/NetworkManager.cs:980)
Unity.Netcode.NetworkManager.NetworkUpdate (Unity.Netcode.NetworkUpdateStage updateStage) (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.6.0/Runtime/Core/NetworkManager.cs:70)
Unity.Netcode.NetworkUpdateLoop.RunNetworkUpdateStage (Unity.Netcode.NetworkUpdateStage updateStage) (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.6.0/Runtime/Core/NetworkUpdateLoop.cs:185)
Unity.Netcode.NetworkUpdateLoop+NetworkPostLateUpdate+<>c.b__0_0 () (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.6.0/Runtime/Core/NetworkUpdateLoop.cs:268)
I don't have a sample project I can share, but according to the error message no custom scripts are involved.
Reproduced in play mode and in windows build.
Environment
- OS: Windows 10 220H2
- Unity Version: 2023.3.12.f1
- Netcode Version: 1.6.0 / 1.7.0
Description
When the host disconnects and a certain object is not owned by the server, the following NullReferenceException is thrown:
I don't have a sample project I can share, but according to the error message no custom scripts are involved.
Reproduced in play mode and in windows build.
Environment