Authoritative server and custom player models.

I started on the networking for our current project, and Unity’s networking abstraction is confusing me a fair bit. I’ll explain what I’m trying to do, and then the problems I’m getting.

The game is a networked vehicle combat game, but we want physics involved, so after looking through the forums on the problems involved with physics and networking we have gone for an authoritative server setup. We also have a custom vehicle creator, which allows the end user to mix and match parts to create their vehicle. This caused a few issues, because (correct me if I’m wrong) you can only use Network.Instantiate() with existing prefabs, and even if you could use it with GameObjects made on the fly, I wouldn’t be keen on sending a few meg of data for a couple of minutes of game play.

So the current setup is as follows:
We save the “custom vehicles” into XML for storage on the hard drive. When connecting or starting a game, you select a vehicle setup from the XML’s stored on your hard drive, then on connection, we serialize the XML into a string and send it via an RPC call to the server. The server then creates a base “Construction” prefab object using Network.Instantiate() (so it is the owner), and then constructs the custom vehicle out of the received XML string. This XML string is sent out to the clients and they each construct the vehicle locally.

It’s working up to this point, but the problem is then assigning NetworkView components based on what the vehicle has, and allowing the server to remain the owner of those NetworkViews.

So for a tank, we need 4 NetworkViews, two on the parent object, one to track the transform, the other to track input (via OnSerializeNetworkView()), one on the turret Transform to track rotation of the turret, and one on the Barrel to track rotation of the barrel.

So the question is, when I create these NetworkViews on the client, how can I tell them that the server is in charge of them? Is it possible to sync up NetworkViews on the client and server by just assigning their “owner” variable and “viewID” manually, or is there some really simple fundamental part of the system I am missing?

Heh, check out www.panzerkampf.com to see a project that I am working on :wink:

On the topic, the “client” that calls the instantiate on some object will be the owner of it or which allocates the networkview. So I suggest your client should just send request of instantiating or allocating networkview to the server, whioch would then do as requested and send the message about it back to clients.