I’ve been leaning up against the Unity scripting reference for networking lately, and I’ve set up a server and clients. The clients report they’ve successfully connected to the server every time, but none of the RPC calls make it out of the calling client and over to the other clients.
My problem is: when sending RPCs with any other RPCMode’s than RPCMode.All and RPCMode.AllBuffered, I see no result. That indicates that the RPC never reaches any of the other connected clients and the only receiver of the RPC is itself.
Of course that doesn’t work because you only create your player object locally. RPCs are sent from an object’s networkView to it’s counterpart on another client. The NetworkViewID you allocate is valid on all clients, but it’s not assigned to an object on the other clients. Therefore your RPCs you send are lost because there’s no receiver.
The usual way is to either have a “communication object” in a scene and every peer loads this scene. NetworkViews on scene objects automatically get a NetworkViewID which is the same on each client.
Another way is to use Network.Instantiate which takes care of instantiating th object locally as well as on all other clients. In addition it will sync the NetWorkViewID(s) which automatically gets allocated for the object.
I don’t really like Network.Instantiate since it uses a buffered RPC which can’t be removed that easy. I always use a communication object in a scene.
edit
I’ve made (another) very simple chat example script. Just create an empty GO in a scene and attach the script. It requires a NetworkView which should be automatically attached. Build your game and make sure the scene that contains the GameObject with the script, is the first one in the scenes list (in the build settings).
Start 2, 3 or most instantex of your game and make one the server. Start the server and connect the other clients to the server.