- Home /
Dedicated Server In Seperate Project
We are making a multiplayer game and are concerned about dedicated server performance.
What would the best client-server setup be? It is important that the server handle most or all gameplay interactions to minimize hackability.
Would it be worth it to have the 'Client' and 'Server' be in separate projects so that each has highest performance? Particularly the server rendering as little as possible? How do you sync network view ids, RPCs, and other information between different unity projects?
We realize that there are many different ways to do networking and just want to get some advice on what people think are the best methods.
Answer by asafsitner · Feb 03, 2014 at 08:25 PM
The way we setup our servers for Fields of War, we had the server and the client in different projects, both for performance and security reasons (hacking, cheating, sensitive information etc.)
We had a problem with synchronizing NetworkViewID initially, because if you have a NetworkView in the scene, it will get a unique SceneID.
We ended up not having any NetworkView component that does state snchronization pre-made in the scene, and instead we instantiate all of them at run-time.
The server tells the clients what to instantiate, and which ViewID it should have, it is also the only place where any 'real' data values are kept, such as weapons damage, players health etc.
This way we have maximum authority and security on the server side, and much more focused and small game/server builds.
For instance, the navigation mesh exists only on the server, as clients do not perform any AI calculations while no actual mesh data is kept on the server side, only collision data.
TL;DR - I'd say it's worth it to separate development of the server and client, especially when security and performance matter. It's not that big a headache.
Thanks for your reply, it was helpful.. but how do you actually go about syncing RPCs and such? Do the RPCs from one project get sent to the same class name in the other project?
Yes! As long as the signature is the same, RPCs get called correctly between projects.
One more thing to remember is that you must have an RPC declared in the class in order to send it, even if it does nothing on the sender's side.
So if, for instance, the client needs to send a request for the server to do something, they have to declare the method with the proper parameter list and tag it as RPC even though the method doesn't actually ever gets called on the client side.
Awesome! Thank you so much for your help. I appreciate it. :D
Thanks asafsitner. I have been looking for days on how to do this and not a single tutorial I have seen mentions it. You are my hero of the day.
Answer by Assault · Feb 05, 2018 at 07:53 AM
Thought this was a solution to my problem, but then i realized this answer is not applicable to UNET, but to the legacy network solution in Unity,