So i tried to do something similar not long ago and i ended up doing something like this;
The plan was to create a Client and Server representation using worlds. Client world will receive data and Render, Server world will push simulation forward and push updates to the client to process. It has 3 possible sku’s. Standalone Client, Standalone Server and Local (Client+Server).
So to get this up and running you will need to do the following:
-
Disable automatic world generation:
Set the UNITY_DISABLE_AUTOMATIC_SYSTEM_BOOTSTRAP preprocessor define.
You can add this under:Edit -> Project Settings -> Player: Scripting Define Symbols
-
Setup your own Initialize method
-
Load your own worlds. Write Initialize and Shutdown functions for the PlayerLoop
One approach is to start by dividing the code into 2 flows one for Client and one for Server, and seperate them by namespace (there are tons of ways to do this, i just chose namespace to try the whole flow out). -
Profit?
One thing i noticed is that if you try to use TransformAccessArray or ComponentArray in your code you will most likely need to internalize the entities package and make sure you make the Hooks you need are public. (On line 34 inside Initialize in the * DefaultWorldInitialization .cs* you can see we are adding the hooks.)