I am having an issue trying to figure out OnSerializeNetworkView.
I player1 instantiates an object and can control it. Player2 sees the changes. Then when it is player2s turn, player2 moves it around, but player1 does not see the changes.
I am using a near vanilla version of the example NetworkRigidbody from one of the Unity example code bases.
stream.isWriting is always false on player2, and always true on player1.
So is this a two way thing and I am doing it incorrectly, or does a networkView only work one way?
only he one creating the view can write to it (thats the owner)
all others only can read from it
Thanks! Not the answer I was hoping for but glad to have some clarification.
Is it possible to change ownership without destroying the object and instantiating it again
Not sure.
But I don’t see a reason for it either.
If the owner changed its no longer the same object
but I wouldn’t know any case where this is required on an auto sync object.
Its something you potentially need in RPG, RTS and similar but in those cases you will not be using the syncronization but RPC instead causing syncing makes no sense.
same goes for cases where the amount of data is not fixed size cause the network view serialization expects the same data amount on every sync after the first one.
I feel like what I am trying to do is not all that unique so this baffles me.
Player1 controls the object one turn, then player2 does.
Destroying the player1 object and recreating one with the same position and states would be the possible solution so long as it didn’t lose connection a lot of other scripts had with it which is an absolute pain.
Maybe my view of how Unity networking works is fundamentally flawed?
Its not flawed you just think of it too complicated.
For a situation like this, you wouldn’t set anything for serialization on the view and set it to not do it actually and instead use RPC and send the turn you do to the other player(s) and have some system on the server player that tells you whichs players turn it is.
The sync is only for realtime syncing purpose, like player in an FPS and alike.
If you do stuff turn based its a total overkill for the networking and restricts you significantly enough to kill your motivation at worst.
Where as RPCs are straight forward and plain simple in this case 
Should the concept of RPC be new to you: Its a lot like SendMessage, just that the function is send through the network view to all valid users (depends on the RPCMode you specify) 
I think there is a slight misunderstanding on what I am trying to do. I do require a near realtime sync.
I am using RPC calls to set which turn it is. That is not the problem.
Player1 needs to be able to see what player2 is doing, hence why I am using the NetworkRigidbody script. Basically player1 throws a object and player2 observes the throw, and vice versa. Without going into too much detail the player watching needs to see the object moving around on their screen.
Nothing what you say requires any realtime position sync.
If the player input happens in turns, there is no requirement for the sync to happen in realtime. To take your example: A throw means that player 1 sets physical properties to fire it and a point in time at which that is meant to happen
These informations are all you need to sync theoretically to somewhere replicate it.
Aside of that, RPC can sync it just as well actually, there is no problem with that.
Just send the data through you need and you are fine! (the code you need for interpolation etc is equal on both sides, with RPCs you just call a function while you rely on automagic with the behaviour syncing.
Benefit of RPC is that you define when the sync happens while the view automatic syncing does it at your defined rate, always)
As additional thing to think about I would recommend the authorative server from networking example.
You can do the same here. Send the “throw request” through RPC to the server and let the server throw it and sync it through the view sync with all for example.
cause someONE has to decide about validity anyway
In the case the desired user can’t instantiate (lol) a gameObject and be the immediate owner, someone else (the server) would have to do it instead and give ownership.
But trying to assign any value to networkView.owner results in an error before play (value read only)…and I haven’t seen any function to transfer ownership. So I now doubt it is possible.
For the rest, dreamora said nearly everything (use of RPC to give signals and informations…)