Create a separate Unity project for a headless server

I want to create a headless server that handles my multiplayer game. This will be a more conceptual project, but basically I just want several players (say 3) to move the box. Thus, each player can move the box at the same time (imagine that soccer is moved by several players).

Now I wonder how I should structure my code. I thought that I have a separate project for the server that I can run headless on the linux server, and another project for the game itself. The entire server is a message about where the box is and who moves it.

I am new to Unity, so not sure if this is wise. Or should I put the server in a separate scene in the same project? Or a completely different approach?

+7
design networking server unity3d unity5
source share
1 answer

You are faced with a big question.

Here are three options:

(A) Some people prefer to have both sides in one script . (Obviously in the same project.)

(B) Some people prefer to have two scenarios , but in one project . So, the application starts, and the application then decides whether it is a server or a client.

(C) Some people prefer to have two completely separate projects . Thus, one project is a client, and one is a server.

Some important facts about three:

So, you need to solve three approaches.

Regarding "A":

  • Many of the code samples hanging on the Internet since the early days of Unity are in the form of "A". Over the years, this has become less believable, but overall, the "old Unity code lying on www" poses a danger in general.

  • (Indeed, for this reason, many novice programmers who have learned to program in general using Unity and find Unity snippets on the Internet think or think that you should "use" approach A.)

  • Keep in mind that most of the sample code for Unity on the Internet is completely stupid. In fact, the examples of network patterns that you see are often a prime example of this.

  • Personally, I find the “A” approach surprisingly confusing and meaningless. Indeed, for many years I tried to understand what could be. The only advantage I could ever find was saving disk space. so instead of two scenarios, you get one — it can save per kilobyte of space on your disks. I can’t, myself, see any other goals related to combining two concepts in one.

Regarding "B":

  • Perhaps this is the way for medium-sized projects. The disadvantage here is that the application must know fundamentally in order to divide itself into two different applications.

  • If deployment is important, if it should be “GI Proof,” B is simpler than C (for those who deploy it, they just launch “some kind of application” and the developer himself doesn’t need to determine which application to deploy, how often, etc.); but then it’s harder for developers.

Regarding "C":

  • If the system (say) does something with security or transactions, you will want to do it so that everything is KISS, and there is less chance of failure due to confusion. If the two parts of the system are naturally more different, it makes sense to do this anyway. (If the two sides of the system are very similar, you will lean towards B.)

  • If the project is very large (i.e. many engineers), of course, C is simply simpler, since it is more broken. This will make you more naturally formalize the communication protocol between them, etc.

C is always "correct." B may be useful for ease of deployment. And of course, if you just run the "hello world" test, A is useful (if confusing).


In order to get a further opinion on this complex issue, a deployment example would have to be clearly presented; those. this is a game in the application store, this is a one-time installation of a kiosk, factory-serial software or whatever. Greetings

+9
source share

All Articles