Greetings!
So just to also get beginners on the same page here:
In Unity networking is usually handled the following way. You make some object (lets say an NPC) and then it contains the code for both server and client side.
Then you can communicate through many different methods: Commands, RPC, SyncVars, and most importantly your own “game messages” (that is, inheriting from MessageBase).
Now it doesn’t really matter what kind of networking solution you use, that principle is pretty standard.
In fact, I was not able to find any networking solution/plugin/library/asset/ whatever you want to call it; that did not rely on this kind of behaviour (same class for client and server objects).
So while I was doing a review of my game and its general architecture recently, I realized that this setup is not really suitable for me, and that I’ll have to drop some concepts / parts that the high-level unity networking API (also known as HLAPI) offers.
To be more specific, I need to have separate classes for each “entity” in my game.
A player-character on the server would be “ServerCharacter : MonoBehaviour”, and on the client the same object would be represented by a “ClientCharacter : MonoBehaviour”.
The reason for this split - from simply “Character” which contains all code, to dedicated Server* and Client* classes - is that I want to have a clean project structure, and making use of the new AssemblyDefinition files in 2017.3.
And this split would make both individual objects more lightweight.
A “ServerCharacter” would not have to have a reference to “UIDisplay” or a “GetHoverCursor()” method.
And on the other side a “ClientCharacter” would not need an “OwningPlayer” property, and tons of other things… Each class would only care about the things it actually needs.
In fact, without this split it would be almost impossible to use AssemblyDefinition files.
How would you make a “Server.dll” and a “Client.dll” ? In which module would your “Character” class even go?
Most bigger games I know have a clear distinction between the server and client objects, and at most they share some common definitions for networking purposes.
Now dear community, do you think splitting up the game into components is worth the effort?
Does the way I think about this make sense to you?
Are there any assets or libraries around that would simplify the creation of a game with this kind of architecture?
What is your opinion on splitting things up like that?