UNET Server and Client business classes

Hello folks!

I’m reading about UNET to create the Networking structure for our MMORPG (Yeah, I know, but we are planning to launch it on the next 6 years). I have some experience on MMORPG but not in Unity, so I’m used to have client and server as separated projects and just share some classes.

But when learning about UNET (I’m on it about 2 days) I understood how it works on Client and Server instances, but I still have a question: How to have Client and Server business specific classes apart? Since we are creating an authoritative server, there will be many classes where only server need to have, and the same applies for client (the server doesn’t need to have some rendering or animation specific classes).

At first I thought on using two Unity Projects, one for Client and one for Server, but this will lead on code duplications, because there are classes (like containers classes such as Player, Monsters and Npc data) that will be used on both - Server and Client.

This may seems a no use question, but I really don’t want to spread all Server specifics classes to all clients, because this will help hackers and cheaters to create tools against our MMORPG. I would like to have a build where client have only its classes and same for the server.

Thanks in advice!

I was able to do it by using custom build script. Here’s a script snippet to do it:

public static void BuildClient()
    string[] levels = { "Assets/Main.unity" };

    Directory.Move("Assets/Scripts/Server/", "Temp/customBuild_Server/");
    BuildPipeline.BuildPlayer(levels, "Build/Client.exe", BuildTarget.StandaloneWindows, BuildOptions.None);
    Directory.Move("Temp/customBuild_Server/", "Assets/Scripts/Server/");

(Place this script inside a Editor folder on Assets)

Any script that is inside Assets/Scripts/Server folder will not be build on Client, so I have safe develop my business needs on server side.

Hope this helps someone else.