I need a GameObject with a NetworkView to perform OnSerializeNetworkView for both the client and the server. Currently the server instantiates the object when it spawns, the code is authoritive to the server but I want rotation to be non authoritive so I need to send it from the Client... except I cant have two Owners of a network view... I could use two networkviews but surely this will increase bandwidth usage. I need to syncronise many variables...
TL:DR How can I define the owner of a networkview? Or make OnSerializeNetworkView work for a client and server however I wish.
I'm not exactly sure what your issue is, but when using OnSerializeNetworkView, the person doing the stream.isWriting is always the person who owns the object on the network.
So you need to plan your Network.Instantiates accordingly, to make sure the ownership is set up correctly. Whoever calls Network.Instantiate will by default be the owner of the networkView of the instantiated object.
For instance, make sure the server is the only instance of the game that runs the code on an enemy spawner, then the server will own the enemy objects that the spawner Network.Instantiates. Then, in the enemy AI code on the enemy object, when you use OnSerializeNetworkView, whatever you put in if(stream.isWriting){} will be the data that the server sends, and whatever is in the else{} clause will be what the clients receive.
I don't believe it's possible to change the owner of a network view.
EDIT - correction:
From this post, I believe that the owner of the network view is the one that allocates the view id. If you wish to make the client the owner, you may be able to instantiate on the server, then on the client allocate it a new view id (Network.AllocateViewID()) and pass that back to the server. This would be much the same as calling Network.Instantiate on the client though...
var players:NetworkPlayer[];
if(NetworkPlayer==players[0]){//if we are the server
//do server specific stuff
}
else {//else we must be a client
//do client specific stuff
}