I’m debating on migrating a project to Unity, but have a couple of questions regarding networking:
-
Are there any articles or documentation on using an authoritative dedicated server? The documentation I have seen thus far uses a player as both client and server.
-
My dedicated server is a linux box, can I deploy the server code unity creates to it?
I believe the following article sufficiently answers my second question.
- Not sure about documentation specific to using Unet in an authoritative server model. That’s what I do in my game, and I just don’t instantiate a player for the server, and make all player objects (in fact all objects) have server authority.
It makes it a bit more tricky to do movement and things like that with your player compared to local player authority, and if your game is fast paced you may want to anticipate what the server will do on the client side so as to not appear to be a delay. In my game it is rather slow paced ocean sailing, so the delay in relaying a key press as a command to the server is hardly noticeable. Something like an FPS though will need a faster solution.
Basically instead of taking input from the user and acting on it with a local player object like in a single player game, you call a Command on the player object, which is then run on the server version of the object. The server version then executes the actual movement, and then all client versions get updated via the network transform component.
- Yes. I just build my server version in headless mode and no issues running it on the Linux server.
This question may answer itself as I learn more about the inner workings of unity, but I must ask.
Where exactly would I start coding my server program. For example, in projects I’ve worked on in the past I would create my game program and within it connect to a server via a domain name and socket.
My server program would exist independently from the game code. I would then compile each separately, send the server to the dedicated server, and the client game to the players.
So in unity, if I were to use the raw network library and code the functionality I need myself, where exactly should that script exist? Should it be applied to a blank game object? Is there a specific place for it?
I haven’t quite reached that “Ah ha” moment with unity, as you can probably tell. 