- Home /
Unity 5.x Network Synchronization Concepts
Bear with me, It will be long read^^
I am working on the new Unity Networking system. I was using Photon and old (legacy) unity network API's before. But as it seems there are some good benefits of the new system than the previous ones, so I want to stick with it. (Despite of it being uncompleted)
But there are some points that doesn't make sense to me with the API. Data Sync for example. So, in the old systems (both in Photon and legacy unet) we had functions called OnPhotonSerializeView or OnSerializeNetworkView depending on which API we use. Both API's are very similar as you may know. So in these functions we could send and recieve data between clients and server. Which makes sense, and was really usefull.
But aperantly they changed this concept, (or it still exists, and i couldn't find it)
There is a new thing called [SyncVar], which syncs the data "ONLY" from server to client automatically. (Which really, literally doesn't make sense, I mean why not sync both server to client AND client to server? That would make everything much easier)
According to the documents, you can ONLY send data from client to server by using [Command]'s. Which is basically (as far as I understand), "one way" version of old good [RPC] calls. Instead of calling function in all other clients, it calls it in the server.
So, you can send data to server with function parameters like the way we did it with the old [RPC]'s before. Which is usefull on point but If this is the only way to send data to server, then it doesn't make any sense to me..
I mean there are variables that needs to be kept synced all the time, back and forth, like position or rotation vectors. And sending them with [Command] calls, contradicts with the concept of network framework in my mind. We used to avoid this kind of situation before, right? Why make it the obligation now?
Or are there simply any other ways to send data from client to server that I couldn't find yet? There is a custom serialization with the [SyncVar], with OnSerialization and OnDeserializaton functions. Which really looks like the good old OnSerialize functions but apperantly it's diffrent as it does what the [SyncVar] does. OnSerialization is only called on server, and Deserialization is only called on client. So we can only send from server to client even with it.
If [Command] is the only way to send data to server, please say so. And clarification about why this concept is reasonable would be really nice.
Please enlighten me more with the new concepts of the new UNET framework. Thanks in advance for any help.