|
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.
(comments are locked)
|
|
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.
(comments are locked)
|
|
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...
(comments are locked)
|
|
use something like A more concise way would be to use Network.isServer. (But this won't help with OnSerializeNetworkView).
Jan 01 '11 at 03:06 PM
Matthew A
cant he use it in the OnSerializeNetworkView()?
Jan 01 '11 at 07:04 PM
YeOldeSnake 1
Well yes, but it's not really relevant who the server is in OnSerializeNetworkView, but whether your writing or reading to the stream, which can be found in Bitstream.isWriting.
Jan 03 '11 at 12:28 PM
Matthew A
(comments are locked)
|
