Search Unity

Network player IDs

Discussion in 'Multiplayer' started by WarpedAxiom, Jan 26, 2008.

  1. WarpedAxiom

    WarpedAxiom

    Joined:
    Oct 27, 2006
    Posts:
    245
    Ahoy hoy.
    I can't really figure out a way to differentiate between players, to assign them team and player numbers etc, and to have them spawn at different locations.
    Especially the spawning is troublesome at the moment, as everyone spawn in a pile and gets stuck.
    Any help appreciated.
    Thanks.
     
  2. jashan

    jashan

    Joined:
    Mar 9, 2007
    Posts:
    3,307
    That can indeed be a little tricky ;-)

    The way I'm solving it (I also have teams and players in those teams) is that I'm keeping ordered lists of teams and players, and also have "Team-Spawning points". A "Team-Spawning point" consists simply of several empty game-objects that are the locations where I instantiate the player game objects. Then, each player game object "pulls" its player / team information from the lists. Those lists are kept synchronous between server and all clients.

    On each client, one "player-object" is owned by that client. This is how I determine which game object is controlled by the user. All player-objects are network-instantiated by the server. I'd say this is not trivial, but it can be handled ;-)

    Jashan
     
  3. larus

    larus

    Unity Technologies

    Joined:
    Oct 12, 2007
    Posts:
    280
    The networking example project does have a simple example of how to initialize clients before they actually spawn their own objects. It's in the Castles scene if I recall correctly and also a bit in the TPS-Auth scene. Its just a case of sending RPCs back and forth as a new client connects, so the server can tell the client where to instantiate his own object, in the case where the server doesn't actually spawn the object for him.

    The spawn position RPC buffer problem was also discussed a bit here: http://forum.unity3d.com/viewtopic.php?t=8595