Probably a longshot… but I am hoping to get into contact with people who have some experience and are willing to help out setting up a standalone server with connecting clients where both client and server code is separated…
Right now I am struggling with the rules of ownership, also there seems to be an issue with the sync to clients that receive remote players positions…
with “NetworkManager” in the subject, I assume you’re using the HLAPI?
If so, and you insist on keeping your projects separate, forget about using Commands & RPCs. You’re pretty much just going to want to send basic messages back & forth, losing most of what makes the HLAPI handy.
I don’t see how it is possible to call a command or rpc in UNet if the script that has that command or rpc is not a part of the project. So the client needs the script with the command just to call it, even though the command is run on the server, and the server needs the script with the rpc even though the rpc is run on the client.
Unless there is some cool trick to doing this that I’m not aware of.
This is a recurring complaint about the UNet design.
For my project, I have it in the plan to try including all contents within commands or the important stuff in server side only scripts within an “#if UNITY_STANDALONE_LINUX” preprocessor directive block (client is win/mac, server is linux), or setup a custom global #define that indicates this is a server which I will remove or comment out when building the client. I haven’t tested it to see if it is a viable solution yet though (if you try it and it is no good, sorry), its just the best idea I’ve been able to come up with where I believe I should be able to use the full HLAPI as intended but leave out a good portion of the server code in client builds.
So, i considered something like this… but, isnt this the same as separating the code? you are building your server or clients without pieces of code here right?
or are we talking here about things like for example a database hook up…
i dont think this is possible and will get very messy
do you know of any active unity officials on these forums maybe?
Until you’re running scripts with same signatures and netId’s on both client and server it will work. So you need only headers of methods. That’s what we do.
E.g.
[Command]
public void CmdSomeCommand(){
// ... Can be empty on client
// On server
// RpcSomeRpc();
}
[ClientRpc]
public void RpcSomeRpc(){
// ... Can be empty on server
DoSomethingOnClient();
}
As for how clean the concept is… Well it works, it fits the needs, and it cuts down LLAPI code a bit. Even though if I would’ve started project right now, I would’ve chosen LLAPI messaging system instead. Since it has more control on message serialization, looks more like “client-server”, and do not rely on UnetWeaver or “host”-idea file structure (you don’t need to have message handlers in same file or even authority for them to work).
You can try doing it yourself, it’s not nuclear science. You can start with bruteforce solution → copying all scripts from host setup and then sorting everyting you want in two separate projects.
Also, make sure CRC check is disabled in NetworkManager settings.
Though I should warn you, at some point you’ll encounter netId missmatch bug (as in any Unet HLAPI project, but it seems to be occuring more often in two different scene PostProcessing).
Make sure you’re not encountering bug mentioned above. And also double or even triple check that SyncVars/SyncLists/SyncStructs and messages are identical in both code bases.
Also, “not working” means you have to debug more. Figure out what’s the reason of it.