com.unity.netcode.gameobjects icon indicating copy to clipboard operation
com.unity.netcode.gameobjects copied to clipboard

Netcode crashing when trying to connect client to host

Open RobTheBoss opened this issue 2 years ago • 1 comments

Using netcode for gameobjects, I'm having a weird problem when trying to connect a client to a host. The client seems unable to even spawn in its player prefab and the game crashes. Here are the errors I get in the console. image

I suspect it has something to do with how I setup my components in the player gameobject. I disabled about half of them to see if the issue would go away but no luck. Here's what it currently looks like image

The only other things I have in the player are two children. One only for the model and the other is empty to store a transform

RobTheBoss avatar Jul 09 '23 03:07 RobTheBoss

I'm assuming you have enabled scene management.

image

This error throwed on me when I instantiated the network object before starting the server. Netcode considers it a "scene object" since it's been there before netcode started. What happens is when the client connects, it tries to find that "scene" object. However, since the object has been created runtime on the server, it obviously doesn't exist.

The process of linking scene objects is called soft synchronization (soft-sync), and it only works if scene management is enabled.

https://docs-multiplayer.unity3d.com/netcode/current/basics/object-spawning/#soft-synchronization

Again, object on the server is created runtime, but is created before the server is started, so netcode considers it a scene object. Client searches for that object on their instance assuming it's part of a scene, and obviously doesn't find it.

powersupersport avatar Jul 12 '23 08:07 powersupersport