NetworkView Control

Hello, Unity and Uniters.

I’ve been using NetworkView to synchronize the state of the GameObject (rigidbody).
They’re running well and I’m satisfied Unity’s Network components.

One issue I have for now is to control the object in both side of server and client.
Now, state synchronization is only one-way and client couldn’t update its objects’ state to the server.
I want to both of server and client to control the same object.
If you have much experiences of network and multiplayer game development in Unity, please let me know the best solution.

I appreciate any advice or help.

solution 1

make an RPC calls from user to server that sends user's controls and applies on the server side, then sends to all users a result of action

solution 2

make (network-instantiate) a dummy (empty) object by user and control it in a normal way. you should not instantiate this object on other remote player's PCs. only on the server. than translate actions of this dummy object to real object on the server.

AFAIK you cannot change a direction of networkView synchronization. it always reads data on object’s instantiator and writes to network copies

I’ve solved this problem at all.

Following is code for client side gameObject with networkVew.

newNetworkId = Network.AllocateViewID();
networkView.RPC("DidAllocateNewId", RPCMode.Others, networkIds[1]);

And following is code for paired server side gameObject wit networkView.

void DidAllocateNewId(NetworkViewID newId) {
	newNetworkId = newId;

And when I needed client-to-server control, I changed the networkView’s id to the new value.

networkView.viewID = networkIds[currentNetworkId];

Hope this help anybody who has the same issues.