I am trying to make a multiplayer game for network, and want to synchronize the game characters between the different maschines.
I’ve tried to search on the Unity documentations and found a guide that told me to use the function OnSerializeNetworkView() and followed the steps in the article but i does not work. The function is never called. (I’ve tried to insert a debug msg in the function and it is never called).
Does anybody have some good surgestions to what might be wrong?
The project is attached to this post.
What I do is, that I am starting a server directly from inside the unity editor, and connecting to it from a built version of my game.
When you join the server you instantiate a character, the same counts when you are starting the server.
The character has a script attached to it with a lot of different properties, such as health, power and armor.
But when I am editing these properties in unity, the client does not update the character which it has instantiated itself.
If I still am not explaining it well enough, maybe you could download the product and see what I mean?
Syncing properties does not happen out of the box, you need to write code for it.
So either you didn’t do that yet or there is a problem with the code.
So please post your code and explain what you are trying to do with it so we can help.
Why don’t you use Photon Networking or a similar system? I haven’t tried it, as my current project has no networking function, but I hear it’s pretty good and superior to Unity’s built in networking.
As for your code, I don’t quite think you’re doing it right…
One of the links on that Web page needs to be changed. The “Photon Viking Demo” link goes to the “Photon Unity Networking” package and not to the “Photon Viking Demo” package.
“Everything needed, is in the package, so we create a new, empty project in Unity. In the Asset Store, search for “Photon Viking Demo” (or click the link). Download and import the package.”