Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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?)

share|improve this question
    
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. –  AbstractChaos Feb 2 '13 at 14:26
    
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) –  ValooFX Feb 2 '13 at 16:16
add comment

1 Answer

up vote 3 down vote accepted

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!

share|improve this answer
    
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). –  ValooFX Feb 2 '13 at 17:18
    
Sorry, now i see that my problem is obviously more software related. I'm going to ask that in the unity forums. –  ValooFX Feb 2 '13 at 17:32
    
Yes. That is probably more platform specific. :( –  Vaughan Hilts Feb 2 '13 at 17:53
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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