- Home /
Unity based server, running each level in separate engine
I have an old game design, dating back to when I didn't even know about Unity. It was a client-server sandbox, where the grand world would be a graph of connected nodes, each node being a complete 2d interactive environment - just like unity scenes normally work.
Client would always be in single node and only that node would be loaded at any point in time, so here there is no problem. Server however would need to load and update every single node that any player is currently in.
This is where I'm unsure about what Unity can realistically allow me to do. Is it possible to create a server, that could run each scene nearly completely separately. This means in a separate instance of actual game engine, with its own update loop and physics worker, running on it's own thread so it can scale with any number of server cores.
I am aware of the hacks where scenes are loaded into another layer and the other method, where each scene is offset in world coordinates. Unfortunately this is not scalable, the first method would be limited to no more than ~20 players at once and the second one would eventually die out of performance, since everything including physics would run on single update thread (unless Unity's game loop supports multithreading in some fashion I'm unaware of?)
I thought for a while about running multiple instances of unity engine itself and use one of inter-process communication to let the levels communicate with world server. But that appears to have one big problem - assets. I'd have to load them for each unity engine instance, wouldn't I? Or is there a way to share a single memory area (unmanaged?) where unity could store and retrieve, for example, prefabs?
Any other solutions that are applicable here?
Will unity ever support such server solution out of the box?
I didn't tried and I am not sure, but maybe few instances of Unity game, each running a game server with different scene, may communicate by RPCs to update each other worlds. As shared resources between game instances, I have to try under Linux to see if is possible to use hard links or symbolic links.
The perfect solution here would be, if Unity could allow saving prefabs and other read-only assets into a memory mapped file storage. This could allow reading them directly, because once created, that data does not have to change (on runtime at least), it only needs to be read, a basic pointer is enough and GC is unnecessary. Such data could be reused by as many unity instances as necessary and average server instance would get smaller by orders of magnitude, making this whole crazy idea quite feasible.
Your answer
Follow this Question
Related Questions
Unity networking tutorial? 6 Answers
FileStream on separate Thread seems to block the main thread 1 Answer
Game data sync with server 0 Answers
Unity, server for game 2 Answers
'Online Game' - Same Wifi 1 Answer