Something Breaks when spawning as Client

Hi,

i have a testing game where i simply join and place a player prefab with ```
NetworkManager.Singleton.StartHost();


I havent worked on the projekt for a few months because of school exams, but It has worked flawlessly before without exceptions

Now everytime i join as a client, the console gets spammed like 40 times with:

```csharp
[Netcode] Failed to create object locally. [globalObjectIdHash=2189284943]. NetworkPrefab could not be found. Is the prefab registered with NetworkManager?
UnityEngine.Debug:LogError (object)
Unity.Netcode.NetworkLog:LogError (string) (at Library/PackageCache/com.unity.netcode.gameobjects@1.1.0/Runtime/Logging/NetworkLog.cs:34)
Unity.Netcode.NetworkSpawnManager:CreateLocalNetworkObject (Unity.Netcode.NetworkObject/SceneObject) (at Library/PackageCache/com.unity.netcode.gameobjects@1.1.0/Runtime/Spawning/NetworkSpawnManager.cs:372)
Unity.Netcode.NetworkObject:AddSceneObject (Unity.Netcode.NetworkObject/SceneObject&,Unity.Netcode.FastBufferReader,Unity.Netcode.NetworkManager) (at Library/PackageCache/com.unity.netcode.gameobjects@1.1.0/Runtime/Core/NetworkObject.cs:1287)
Unity.Netcode.CreateObjectMessage:Handle (Unity.Netcode.NetworkContext&) (at Library/PackageCache/com.unity.netcode.gameobjects@1.1.0/Runtime/Messaging/Messages/CreateObjectMessage.cs:35)
Unity.Netcode.MessagingSystem:ReceiveMessage<Unity.Netcode.CreateObjectMessage> (Unity.Netcode.FastBufferReader,Unity.Netcode.NetworkContext&,Unity.Netcode.MessagingSystem) (at Library/PackageCache/com.unity.netcode.gameobjects@1.1.0/Runtime/Messaging/MessagingSystem.cs:457)
Unity.Netcode.MessagingSystem:HandleMessage (Unity.Netcode.MessageHeader&,Unity.Netcode.FastBufferReader,ulong,single,int) (at Library/PackageCache/com.unity.netcode.gameobjects@1.1.0/Runtime/Messaging/MessagingSystem.cs:387)
Unity.Netcode.MessagingSystem:ProcessIncomingMessageQueue () (at Library/PackageCache/com.unity.netcode.gameobjects@1.1.0/Runtime/Messaging/MessagingSystem.cs:407)
Unity.Netcode.NetworkManager:OnNetworkEarlyUpdate () (at Library/PackageCache/com.unity.netcode.gameobjects@1.1.0/Runtime/Core/NetworkManager.cs:1581)
Unity.Netcode.NetworkManager:NetworkUpdate (Unity.Netcode.NetworkUpdateStage) (at Library/PackageCache/com.unity.netcode.gameobjects@1.1.0/Runtime/Core/NetworkManager.cs:1513)
Unity.Netcode.NetworkUpdateLoop:RunNetworkUpdateStage (Unity.Netcode.NetworkUpdateStage) (at Library/PackageCache/com.unity.netcode.gameobjects@1.1.0/Runtime/Core/NetworkUpdateLoop.cs:185)
Unity.Netcode.NetworkUpdateLoop/NetworkEarlyUpdate/<>c:<CreateLoopSystem>b__0_0 () (at Library/PackageCache/com.unity.netcode.gameobjects@1.1.0/Runtime/Core/NetworkUpdateLoop.cs:208)

and:

Failed to spawn NetworkObject for Hash 2189284943.
UnityEngine.Debug:LogError (object)
Unity.Netcode.NetworkObject:AddSceneObject (Unity.Netcode.NetworkObject/SceneObject&,Unity.Netcode.FastBufferReader,Unity.Netcode.NetworkManager) (at Library/PackageCache/com.unity.netcode.gameobjects@1.1.0/Runtime/Core/NetworkObject.cs:1292)
Unity.Netcode.CreateObjectMessage:Handle (Unity.Netcode.NetworkContext&) (at Library/PackageCache/com.unity.netcode.gameobjects@1.1.0/Runtime/Messaging/Messages/CreateObjectMessage.cs:35)
Unity.Netcode.MessagingSystem:ReceiveMessage<Unity.Netcode.CreateObjectMessage> (Unity.Netcode.FastBufferReader,Unity.Netcode.NetworkContext&,Unity.Netcode.MessagingSystem) (at Library/PackageCache/com.unity.netcode.gameobjects@1.1.0/Runtime/Messaging/MessagingSystem.cs:457)
Unity.Netcode.MessagingSystem:HandleMessage (Unity.Netcode.MessageHeader&,Unity.Netcode.FastBufferReader,ulong,single,int) (at Library/PackageCache/com.unity.netcode.gameobjects@1.1.0/Runtime/Messaging/MessagingSystem.cs:387)
Unity.Netcode.MessagingSystem:ProcessIncomingMessageQueue () (at Library/PackageCache/com.unity.netcode.gameobjects@1.1.0/Runtime/Messaging/MessagingSystem.cs:407)
Unity.Netcode.NetworkManager:OnNetworkEarlyUpdate () (at Library/PackageCache/com.unity.netcode.gameobjects@1.1.0/Runtime/Core/NetworkManager.cs:1581)
Unity.Netcode.NetworkManager:NetworkUpdate (Unity.Netcode.NetworkUpdateStage) (at Library/PackageCache/com.unity.netcode.gameobjects@1.1.0/Runtime/Core/NetworkManager.cs:1513)
Unity.Netcode.NetworkUpdateLoop:RunNetworkUpdateStage (Unity.Netcode.NetworkUpdateStage) (at Library/PackageCache/com.unity.netcode.gameobjects@1.1.0/Runtime/Core/NetworkUpdateLoop.cs:185)
Unity.Netcode.NetworkUpdateLoop/NetworkEarlyUpdate/<>c:<CreateLoopSystem>b__0_0 () (at Library/PackageCache/com.unity.netcode.gameobjects@1.1.0/Runtime/Core/NetworkUpdateLoop.cs:208)

in between the mess i also found this:

OverflowException: Reading past the end of the buffer
Unity.Netcode.NetworkObject.AddSceneObject (Unity.Netcode.NetworkObject+SceneObject& sceneObject, Unity.Netcode.FastBufferReader variableData, Unity.Netcode.NetworkManager networkManager) (at Library/PackageCache/com.unity.netcode.gameobjects@1.1.0/Runtime/Core/NetworkObject.cs:1305)
Unity.Netcode.CreateObjectMessage.Handle (Unity.Netcode.NetworkContext& context) (at Library/PackageCache/com.unity.netcode.gameobjects@1.1.0/Runtime/Messaging/Messages/CreateObjectMessage.cs:35)
Unity.Netcode.MessagingSystem.ReceiveMessage[T] (Unity.Netcode.FastBufferReader reader, Unity.Netcode.NetworkContext& context, Unity.Netcode.MessagingSystem system) (at Library/PackageCache/com.unity.netcode.gameobjects@1.1.0/Runtime/Messaging/MessagingSystem.cs:457)
Unity.Netcode.MessagingSystem.HandleMessage (Unity.Netcode.MessageHeader& header, Unity.Netcode.FastBufferReader reader, System.UInt64 senderId, System.Single timestamp, System.Int32 serializedHeaderSize) (at Library/PackageCache/com.unity.netcode.gameobjects@1.1.0/Runtime/Messaging/MessagingSystem.cs:387)
UnityEngine.Debug:LogException(Exception)
Unity.Netcode.MessagingSystem:HandleMessage(MessageHeader&, FastBufferReader, UInt64, Single, Int32) (at Library/PackageCache/com.unity.netcode.gameobjects@1.1.0/Runtime/Messaging/MessagingSystem.cs:391)
Unity.Netcode.MessagingSystem:ProcessIncomingMessageQueue() (at Library/PackageCache/com.unity.netcode.gameobjects@1.1.0/Runtime/Messaging/MessagingSystem.cs:407)
Unity.Netcode.NetworkManager:OnNetworkEarlyUpdate() (at Library/PackageCache/com.unity.netcode.gameobjects@1.1.0/Runtime/Core/NetworkManager.cs:1581)
Unity.Netcode.NetworkManager:NetworkUpdate(NetworkUpdateStage) (at Library/PackageCache/com.unity.netcode.gameobjects@1.1.0/Runtime/Core/NetworkManager.cs:1513)
Unity.Netcode.NetworkUpdateLoop:RunNetworkUpdateStage(NetworkUpdateStage) (at Library/PackageCache/com.unity.netcode.gameobjects@1.1.0/Runtime/Core/NetworkUpdateLoop.cs:185)
Unity.Netcode.<>c:<CreateLoopSystem>b__0_0() (at Library/PackageCache/com.unity.netcode.gameobjects@1.1.0/Runtime/Core/NetworkUpdateLoop.cs:208)

and this:

[Netcode] NetworkPrefab hash was not found! In-Scene placed NetworkObject soft synchronization failure for Hash: 16777216!
UnityEngine.Debug:LogError (object)
Unity.Netcode.NetworkLog:LogError (string) (at Library/PackageCache/com.unity.netcode.gameobjects@1.1.0/Runtime/Logging/NetworkLog.cs:34)
Unity.Netcode.NetworkSpawnManager:CreateLocalNetworkObject (Unity.Netcode.NetworkObject/SceneObject) (at Library/PackageCache/com.unity.netcode.gameobjects@1.1.0/Runtime/Spawning/NetworkSpawnManager.cs:391)
Unity.Netcode.NetworkObject:AddSceneObject (Unity.Netcode.NetworkObject/SceneObject&,Unity.Netcode.FastBufferReader,Unity.Netcode.NetworkManager) (at Library/PackageCache/com.unity.netcode.gameobjects@1.1.0/Runtime/Core/NetworkObject.cs:1287)
Unity.Netcode.SceneEventData:SynchronizeSceneNetworkObjects (Unity.Netcode.NetworkManager) (at Library/PackageCache/com.unity.netcode.gameobjects@1.1.0/Runtime/SceneManagement/SceneEventData.cs:864)
Unity.Netcode.NetworkSceneManager:HandleClientSceneEvent (uint) (at Library/PackageCache/com.unity.netcode.gameobjects@1.1.0/Runtime/SceneManagement/NetworkSceneManager.cs:1781)
Unity.Netcode.NetworkSceneManager:ClientLoadedSynchronization (uint) (at Library/PackageCache/com.unity.netcode.gameobjects@1.1.0/Runtime/SceneManagement/NetworkSceneManager.cs:1747)
Unity.Netcode.NetworkSceneManager:OnClientBeginSync (uint) (at Library/PackageCache/com.unity.netcode.gameobjects@1.1.0/Runtime/SceneManagement/NetworkSceneManager.cs:1676)
Unity.Netcode.NetworkSceneManager:HandleClientSceneEvent (uint) (at Library/PackageCache/com.unity.netcode.gameobjects@1.1.0/Runtime/SceneManagement/NetworkSceneManager.cs:1774)
Unity.Netcode.NetworkSceneManager:HandleSceneEvent (ulong,Unity.Netcode.FastBufferReader) (at Library/PackageCache/com.unity.netcode.gameobjects@1.1.0/Runtime/SceneManagement/NetworkSceneManager.cs:1961)
Unity.Netcode.SceneEventMessage:Handle (Unity.Netcode.NetworkContext&) (at Library/PackageCache/com.unity.netcode.gameobjects@1.1.0/Runtime/Messaging/Messages/SceneEventMessage.cs:24)
Unity.Netcode.MessagingSystem:ReceiveMessage<Unity.Netcode.SceneEventMessage> (Unity.Netcode.FastBufferReader,Unity.Netcode.NetworkContext&,Unity.Netcode.MessagingSystem) (at Library/PackageCache/com.unity.netcode.gameobjects@1.1.0/Runtime/Messaging/MessagingSystem.cs:457)
Unity.Netcode.MessagingSystem:HandleMessage (Unity.Netcode.MessageHeader&,Unity.Netcode.FastBufferReader,ulong,single,int) (at Library/PackageCache/com.unity.netcode.gameobjects@1.1.0/Runtime/Messaging/MessagingSystem.cs:387)
Unity.Netcode.MessagingSystem:ProcessIncomingMessageQueue () (at Library/PackageCache/com.unity.netcode.gameobjects@1.1.0/Runtime/Messaging/MessagingSystem.cs:407)
Unity.Netcode.NetworkManager:OnNetworkEarlyUpdate () (at Library/PackageCache/com.unity.netcode.gameobjects@1.1.0/Runtime/Core/NetworkManager.cs:1581)
Unity.Netcode.NetworkManager:NetworkUpdate (Unity.Netcode.NetworkUpdateStage) (at Library/PackageCache/com.unity.netcode.gameobjects@1.1.0/Runtime/Core/NetworkManager.cs:1513)
Unity.Netcode.NetworkUpdateLoop:RunNetworkUpdateStage (Unity.Netcode.NetworkUpdateStage) (at Library/PackageCache/com.unity.netcode.gameobjects@1.1.0/Runtime/Core/NetworkUpdateLoop.cs:185)
Unity.Netcode.NetworkUpdateLoop/NetworkEarlyUpdate/<>c:<CreateLoopSystem>b__0_0 () (at Library/PackageCache/com.unity.netcode.gameobjects@1.1.0/Runtime/Core/NetworkUpdateLoop.cs:208)

and at the end there was this:

OverflowException: Reading past the end of the buffer
Unity.Netcode.ByteUnpacker.ReadUInt32Packed (Unity.Netcode.FastBufferReader reader, System.UInt32& value) (at Library/PackageCache/com.unity.netcode.gameobjects@1.1.0/Runtime/Serialization/ByteUnpacker.cs:554)
Unity.Netcode.SceneEventData.SynchronizeSceneNetworkObjects (Unity.Netcode.NetworkManager networkManager) (at Library/PackageCache/com.unity.netcode.gameobjects@1.1.0/Runtime/SceneManagement/SceneEventData.cs:858)
Unity.Netcode.NetworkSceneManager.HandleClientSceneEvent (System.UInt32 sceneEventId) (at Library/PackageCache/com.unity.netcode.gameobjects@1.1.0/Runtime/SceneManagement/NetworkSceneManager.cs:1781)
Unity.Netcode.NetworkSceneManager.ClientLoadedSynchronization (System.UInt32 sceneEventId) (at Library/PackageCache/com.unity.netcode.gameobjects@1.1.0/Runtime/SceneManagement/NetworkSceneManager.cs:1747)
Unity.Netcode.NetworkSceneManager.OnClientBeginSync (System.UInt32 sceneEventId) (at Library/PackageCache/com.unity.netcode.gameobjects@1.1.0/Runtime/SceneManagement/NetworkSceneManager.cs:1676)
Unity.Netcode.NetworkSceneManager.HandleClientSceneEvent (System.UInt32 sceneEventId) (at Library/PackageCache/com.unity.netcode.gameobjects@1.1.0/Runtime/SceneManagement/NetworkSceneManager.cs:1774)
Unity.Netcode.NetworkSceneManager.HandleSceneEvent (System.UInt64 clientId, Unity.Netcode.FastBufferReader reader) (at Library/PackageCache/com.unity.netcode.gameobjects@1.1.0/Runtime/SceneManagement/NetworkSceneManager.cs:1961)
Unity.Netcode.SceneEventMessage.Handle (Unity.Netcode.NetworkContext& context) (at Library/PackageCache/com.unity.netcode.gameobjects@1.1.0/Runtime/Messaging/Messages/SceneEventMessage.cs:24)
Unity.Netcode.MessagingSystem.ReceiveMessage[T] (Unity.Netcode.FastBufferReader reader, Unity.Netcode.NetworkContext& context, Unity.Netcode.MessagingSystem system) (at Library/PackageCache/com.unity.netcode.gameobjects@1.1.0/Runtime/Messaging/MessagingSystem.cs:457)
Unity.Netcode.MessagingSystem.HandleMessage (Unity.Netcode.MessageHeader& header, Unity.Netcode.FastBufferReader reader, System.UInt64 senderId, System.Single timestamp, System.Int32 serializedHeaderSize) (at Library/PackageCache/com.unity.netcode.gameobjects@1.1.0/Runtime/Messaging/MessagingSystem.cs:387)
UnityEngine.Debug:LogException(Exception)
Unity.Netcode.MessagingSystem:HandleMessage(MessageHeader&, FastBufferReader, UInt64, Single, Int32) (at Library/PackageCache/com.unity.netcode.gameobjects@1.1.0/Runtime/Messaging/MessagingSystem.cs:391)
Unity.Netcode.MessagingSystem:ProcessIncomingMessageQueue() (at Library/PackageCache/com.unity.netcode.gameobjects@1.1.0/Runtime/Messaging/MessagingSystem.cs:407)
Unity.Netcode.NetworkManager:OnNetworkEarlyUpdate() (at Library/PackageCache/com.unity.netcode.gameobjects@1.1.0/Runtime/Core/NetworkManager.cs:1581)
Unity.Netcode.NetworkManager:NetworkUpdate(NetworkUpdateStage) (at Library/PackageCache/com.unity.netcode.gameobjects@1.1.0/Runtime/Core/NetworkManager.cs:1513)
Unity.Netcode.NetworkUpdateLoop:RunNetworkUpdateStage(NetworkUpdateStage) (at Library/PackageCache/com.unity.netcode.gameobjects@1.1.0/Runtime/Core/NetworkUpdateLoop.cs:185)
Unity.Netcode.<>c:<CreateLoopSystem>b__0_0() (at Library/PackageCache/com.unity.netcode.gameobjects@1.1.0/Runtime/Core/NetworkUpdateLoop.cs:208)

Does anybody know what the issue is?

Did something change or did i manage to break something?

Hi @Schlucht , is the prefab you’re trying to spawn in the list of spawnable objects of the NetworkManager? If yes, does removing and re-assigning it fix the issue?

1 Like

Well it is set Player Prefab only. I just tried adding it to the NetworkPrefabs list, but it didn´t seem to change anything.

Removing it as Player prefab and re-assigning also didn´t fix it.

@Schlucht what Netcode For GameObject version are you using? Can you please post a screenshot of your NetworkManager’s inspector? Does the player have a NetworkObject script attached to it?

My Netcode version is 1.1.0. The player has the NetworkObject script on it.

Screenshots are attached


Thanks, is the capsule your player? Can you updated to the latest NGO version?

Yes the Capsule object is my player. The project is already older than a year and i never bothered renaming him XD

NGO is now on Version 1.2.0, but issue still there.

Got it, if you change the player prefab with an empty one that only has the NetworkObject component, dos the error still appear? You can also try emptying the list of spawnable objects to see if the error pops up again, and what is causing it.

K, clearing the List did not work but changing the player prefab fixed the issue

I have exactly the same problem… when I connect a client running in the editor to a host running on a build, I get several of these errors:

[Netcode] NetworkPrefab hash was not found! In-Scene placed NetworkObject soft synchronization failure for Hash: 511921737!
[Netcode] Failed to spawn NetworkObject for Hash 511921737.

The errors persist even replacing the player prefab with an empty network object or reseting the whole list.

I don’t get the error running the game after building though (one host and one client).

Okay, yesterday I made a duplicate of my player prefab and started removing some components, I came to the conclusion that my base script of the player is causing the issue, due to after removing only that it works fine. Apparently I was wrong and may have made a change that breaks the system before I paused the project.

Or maybe the component itself is the issue, it is hard to tell when the Error Logs don’t give coherent information where it is generated.

I will start sequentially debugging my script and see if any statements are causing the error, let’s see what I can find.

1 Like

Awesome, happy to see that you manage to move forward! :smile:

Apparently I just fixed the issue. After getting no information on where the error was caused, then i have decided today to completely removed the base player script and paste the code in a new one. It seems the issue was because of the component ID or “Local ID in File” or something. It completely works fine now.

My mistake, it worked for 20 seconds and then it broke again XD

@Schlucht would it be possible for you to open a bug report here? In this way, the team behind Netcode For GameObject will be able to prioritize your fix, and you’ll be automatically updated about its status.

Hi, yesterday I have found out what the issue was caused by. After an intense logging and debugging session, I was able to figure out that two functions in my script were causing the error, because the network objects they were generating were indeed not in the network prefabs list of the network manager. Therefore, it is finally working out.

Is therefore still a demand for a bug report?

Thanks for the update! I’d say that there’s no need for a bug report in this case

i have similear problem but i dont have a clue -
[Netcode] Failed to create object locally. [globalObjectIdHash=0]. NetworkPrefab could not be found. Is the prefab registered with NetworkManager?
UnityEngine.Debug:LogError (object)

Hi @firebird721 , did you add the prefab to the list of spawnable objects of the NetworkManager? What NGO version are you using?

I suppose after you spawn it you just add it to the manager like he said? I had a similar issue except for the host has the item but the client just doesn’t see it because of a similar error.