Some Basic Networking Questions

I’ve done plenty of research in the forums, I’ve done the tutorials and I’ve read through all of the UNET documentation. Nonetheless, I’m running into a multitude of errors at every turn, in trying to implement multiplayer networking. I’ve written down some basic questions that I can’t find answers to, and maybe this will help me:

  1. How does UNET handle objects that start from the Hierarchy? Are they automatically spawned on all clients and the server?
  2. If I run a Server on Unity, and run a client from a Build of the game, will the error messages from the client appear in the Unity console? If I run Unity as a Host, will error messages from both server and client appear in the Unity console?
  3. What exactly do isServer and isClient check for? I have one line of code that checks for “isServer” and is never true on any instance of my game, even though I have a server running. This script is attached to a game object that starts from the Hierarchy, which pertains to my first question.

Thank you for your time, if you do answer any of my questions.

I’ll take a stab at these -

How does UNET handle objects that start from the Hierarchy? Are they automatically spawned on all clients and the server?

Yes, they will be automatically ‘spawned’ for both server & client. If you look at them in the inspector while the game is running, you’ll see that the host player has automatically assigned it a net id and that should be the same net id for both server & client

2. If I run a Server on Unity, and run a client from a Build of the game, will the error messages from the client appear in the Unity console? If I run Unity as a Host, will error messages from both server and client appear in the Unity console?

Generally, error message in one instance of the game will NOT appear for other players. So like if player A has an Exception, the other players won’t see it the Exception. Keep in mind that hitting an exception can generally cause the session to go sideways, so you may end up seeing errors of other kinds in other players’ games once this happens.

Also, if you do make a client build, you can see error messages for that client automatically if you make a development/debug build. it’s a check mark in Build Settings.

What exactly do isServer and isClient check for?

They pretty much do what is described in the documentation. isServer and isLocalPlayer have always been very accurate & reliable for me, so I’m not exactly sure what is going on. make sure your NetworkBehaviour’d gameobject also has a NetworkIdentity component on it. Also if you’re loading the scene, you may want to make sure you do it the ‘unet way’. I forget the exact details of this, but I think it may do some extra work to link up those NetworkIdentities when the scene finishes loading.