Not syncing Network Prefabs between client and server when joining

Hello, I’m using Relay and when one of my clients joins the host I get thrown these error messages on the client [SceneEventData- Scene Handle Mismatch] serverSceneHandle (-1326) could not be found in ServerSceneHandleToClientSceneHandle. Using the currently active scene. and [Netcode] NetworkPrefab hash was not found! In-Scene placed NetworkObject soft synchronization failure for Hash: 1583715797!
This is happening because I have two network objects that are in the scene before the client joins the server and I want these objects to sync with the server ones. I’m able to get it working by despawning and respawning the objects on the host after the client joins but these errors are still thrown because they occur when the client joins. How can I fix these errors from being thrown?

These must not already be in the client-side scene!

The client has to tell the server to spawn networked objects via RPC, or the server knows to spawn them when a client connects.

1 Like

I’ve removed the objects from the client side scene before joining but I’m still getting the errors, what else can I do to fix this?

I couldn’t find a conclusive reason that causes the error. Can you try reproducing the problem in a test project that you can share?

Before I do that is it possible it’s because I have the objects in Dont Destroy On Load?

There was an old issue related to that, you’d have to see if that makes a difference.

1 Like

Yep, I removed the DDOL on the Network Object and it started working. I placed the object in all the scenes so it now seems to be syncing correctly.

1 Like

I’ve got a different error that’s happening when a client joins the game. I’m not running anything that’s destroying the objects but something is destroying it and this is running on the client. How can I fix this?
[Netcode] [Invalid Destroy][Scene RPC Manager(Clone)][NetworkObjectId:3] Destroy a spawned NetworkObject on a non-host client is not valid. Call Destroy or Despawn on the server/host instead. UnityEngine.Debug:LogError (object) Unity.Netcode.NetworkLog:LogError (string) (at ./Library/PackageCache/com.unity.netcode.gameobjects@f2477a6c90fe/Runtime/Logging/NetworkLog.cs:34) Unity.Netcode.NetworkLog:LogServer (string,Unity.Netcode.NetworkLog/LogType) (at ./Library/PackageCache/com.unity.netcode.gameobjects@f2477a6c90fe/Runtime/Logging/NetworkLog.cs:98) Unity.Netcode.NetworkLog:LogErrorServer (string) (at ./Library/PackageCache/com.unity.netcode.gameobjects@f2477a6c90fe/Runtime/Logging/NetworkLog.cs:58) Unity.Netcode.NetworkObject:OnDestroy () (at ./Library/PackageCache/com.unity.netcode.gameobjects@f2477a6c90fe/Runtime/Core/NetworkObject.cs:1612)

This error is occurring on the host
[Netcode-Server Sender=1] [Invalid Destroy][Scene RPC Manager(Clone)][NetworkObjectId:3] Destroy a spawned NetworkObject on a non-host client is not valid. Call Destroy or Despawn on the server/host instead. UnityEngine.Debug:LogError (object) Unity.Netcode.NetworkLog:LogErrorServerLocal (string,ulong) (at ./Library/PackageCache/com.unity.netcode.gameobjects@f2477a6c90fe/Runtime/Logging/NetworkLog.cs:129) Unity.Netcode.ServerLogMessage:Handle (Unity.Netcode.NetworkContext&) (at ./Library/PackageCache/com.unity.netcode.gameobjects@f2477a6c90fe/Runtime/Messaging/Messages/ServerLogMessage.cs:62) Unity.Netcode.NetworkMessageManager:ReceiveMessage<Unity.Netcode.ServerLogMessage> (Unity.Netcode.FastBufferReader,Unity.Netcode.NetworkContext&,Unity.Netcode.NetworkMessageManager) (at ./Library/PackageCache/com.unity.netcode.gameobjects@f2477a6c90fe/Runtime/Messaging/NetworkMessageManager.cs:563) Unity.Netcode.NetworkMessageManager:HandleMessage (Unity.Netcode.NetworkMessageHeader&,Unity.Netcode.FastBufferReader,ulong,single,int) (at ./Library/PackageCache/com.unity.netcode.gameobjects@f2477a6c90fe/Runtime/Messaging/NetworkMessageManager.cs:422) Unity.Netcode.NetworkMessageManager:ProcessIncomingMessageQueue () (at ./Library/PackageCache/com.unity.netcode.gameobjects@f2477a6c90fe/Runtime/Messaging/NetworkMessageManager.cs:448) Unity.Netcode.NetworkManager:NetworkUpdate (Unity.Netcode.NetworkUpdateStage) (at ./Library/PackageCache/com.unity.netcode.gameobjects@f2477a6c90fe/Runtime/Core/NetworkManager.cs:332) Unity.Netcode.NetworkUpdateLoop:RunNetworkUpdateStage (Unity.Netcode.NetworkUpdateStage) (at ./Library/PackageCache/com.unity.netcode.gameobjects@f2477a6c90fe/Runtime/Core/NetworkUpdateLoop.cs:191) Unity.Netcode.NetworkUpdateLoop/NetworkEarlyUpdate/<>c:<CreateLoopSystem>b__0_0 () (at ./Library/PackageCache/com.unity.netcode.gameobjects@f2477a6c90fe/Runtime/Core/NetworkUpdateLoop.cs:214)

That’s a weird error to see on the host, I don’t know how you would deliberately cause that error so I can’t guess at the cause. I’d need to to be able to reproduce the issue this end to get an idea on what’s going on.

Can you reproduce it in a test project (without Relay) so I can take a look at it?

1 Like

I just changed it back to DDOL and it started working again, I don’t know why this worked. Anyways, thanks for the help.

Hmm sounds a little flakey to me but I’ll keep my fingers crossed for you. :smiley: