ClientScene.AddPlayer resulting in 'Unknown message ID' error

Hi, I have a test Unity networking project where in the menu scene I have implemented the NetworkManager class and have disabled player auto creation. When a server starts a game using matchmaker and a client then joins that game, the server then changes the scene to the ‘Game’ scene. Both the server and the client successfully load this scene and the sever instantiates it’s prefab and and calls NetworkServer.Spawn to show it on client. Up to this point the code and works and both the server and client can see the server’s spawned object, however when I call ClientScene.AddPlayer on the client to send a message to the server to create the client’s player, it results in an error on the server machine and OnServerAddPlayer is not called. The error is :

Unknown message ID 37 connId:1
UnityEngine.Networking.NetworkIdentity:UNetStaticUpdate()

Has anyone else ran into this or a similar issue?

thanks

I think you mean to use

http://docs.unity3d.com/ScriptReference/Networking.NetworkManager.OnClientConnect.html

instead of “OnClientConnected”.

The properly named function will support the message.

Also, I think you are meant to spawn the prefab first then register the spawned gameobject in the function AddPlayerForConnection.

When a SYSTEM_ADD_PLAYER message
handler has received a request from a
player, the server should call this
when he’s created the player’s object.

Also, OnClientConnect is a Client side function whilst AddPlayerForConnection appears to be serverside. On a host machine you have both client and server together so that function will be accessed twice. You need to use if(isServer) if(isClient) (or !isServer etc) to only run the appropriate code on the appropriate setup.