How is the typical login, loading the level and spawning handled?
For example:

  1. Client sends "iwanttologinwithcharacterx"
  2. Server does some validity checks and instantiates characterx
  3. Server sends back "loadlevelx"
  4. Client sends "iaminloadingscreen", when finished sends "finishedloading"
  5. Server sends "spawnyourcharacterx"

OR just after the "iwanttologinwithcharacterx" the server tells the client to handle steps 3, 4, and 5 without interaction?

I'm confused about what would be the ideal approach with the least room for errors.

Some info: The level in which players begin is always the same. Players can have multiple characters and during the game they often switch levels (this would be linked to my first question, how would I handle that cleanly? Don't destroy the playerobject between level load and just change their positions accordingly?)

  • \$\begingroup\$ if all levels are same for players the client can have a local copy so the servers need only to send position of where the user was last and the client renders the level at that position. \$\endgroup\$ – AbstractChaos Feb 2 '13 at 14:26
  • \$\begingroup\$ thx to byte56 for cleaning up my post. @AbstractChaos: I'm a litte confused by your answer. All players have clientsoftware with with level-copies in the first place. rendering is handled by the engine (Unity) and synchronization is not a problem (already implemented) \$\endgroup\$ – Flavelius Feb 2 '13 at 16:16

Your process is generally the right idea for a basic, generic multi player game without any specific design goals. However, there is a lot of stuff you should keep in mind that the client/server does not need to be doing. I'm going to list your steps again and annotate them.

Client sends "iwanttologinwithcharacterx"

Yes, this is an obviously needed step. Be sure to store a token and add them to the logged in list - at this point your server knows the login is valid.

Server does some validity checks and instantiates characterx

Nothing to say here.

Server sends back "loadlevelx"

The server can do this but alternatively if they always spawn in the same zone, then the client can load this from a local cache. I advise you send down a 'revision ID' of the map if your game patcher does not handle level patching - this can then be used to verify later whether or not the client would like a new copy of the map.

Client sends "iaminloadingscreen", when finished sends "finishedloading"

This is an unnecessary step in most cases, the client does not need to let the server know. Instead, the client can perhaps cross-compare the expected revision ID here and send a 'I need a new map cache' from the server. This gives the added benefit of map caching and live-editing.

Server sends "spawnyourcharacterx"

This can be be performed at any point in between, and you can probably spawn it while the map is loading.

Hope this helps!

| improve this answer | |
  • \$\begingroup\$ that clears things up a bit. I'm just a litte unsure about how the server knows when the client is ready or vice versa. After the "iwanttologin..." message, do i just preload the level (at the client) without confirmation from the server (Login is a different "level" than levelX =scenes in Unity)? The thing is, i have to manually connect server and client -player instances (using unitys networkviews). that's the core problem of my question. In the past i had some problems with instances not connecting correctly in the process (while loading the level). \$\endgroup\$ – Flavelius Feb 2 '13 at 17:18
  • \$\begingroup\$ Sorry, now i see that my problem is obviously more software related. I'm going to ask that in the unity forums. \$\endgroup\$ – Flavelius Feb 2 '13 at 17:32
  • \$\begingroup\$ Yes. That is probably more platform specific. :( \$\endgroup\$ – Vaughan Hilts Feb 2 '13 at 17:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.