Networking RPC calls never sent to other clients

Hello,

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.

Here’s my server initialization script: http://pastebin.com/q0hNRkXq

And here’s my client’s “connect to server” script, which sends two RPCs: http://pastebin.com/H2Wg6ZWc

Lastly there’s the client-side script that handles incoming RPCs: http://pastebin.com/vzwMkSzn

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.

As I’ve been leaning up against the Unity scripting reference (http://docs.unity3d.com/Documentation/Components/NetworkReferenceGuide.html), why it doesn’t work is greatly confusing to me - because I’ve done as the reference says, as far as I’m aware of.

Do I need some sort of RPC forwarding script on the server?
Why can’t two connected clients communicate when they’re connected to the same server?

I’ll greatly appreciate any attempted help!

Thank you very much

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.