How do I link Lobby Players to Unity NGO NetworkObjects?

Sorry if this is somewhere in the docs but I am struggling with a sensible way to link my Player instances (that exist in the Lobby) with spawned NetworkObjects. Is there a simple way of doing this?

Here is the context:

  • I am using a Lobby which is working super-well.
  • When sufficient Players have joined and are “ready” (they have clicked a button that updates a PlayerDataObject to say they are ready), then the host can click “start game”
  • When “start game” is clicked, a lobby DataObject is updated to say “ServerStarted” - the host NetworkManager triggers StartHost
  • The client reads the ServerStarted DataObject and this triggers the client NetworkManager to StartClient
  • Both instances of NetworkObjects appear on both Host and Client.
  • But is there a way to tell the NetworkManager which Player.Id belongs to which?

My Lobby Player object carries some useful data like the colour, the player name, etc. It feels like there should be a key to validate that they are both part of the same authenticated player.

Thanks
Ben

1 Like

Haven’t worked with Lobby yet but I’d be surprised if there weren’t a mechanism of mapping Player.Id to NetworkManager’s ClientId - or perhaps they are even the same.

The Boss Room docs mention a SessionManager script which apparantly does such a mapping: Getting started with Boss Room | Unity Multiplayer Networking

This one and ServerCharSelect state manage the transitions between lobby and gameplay

In BossRoom, SessionManager.GetPlayerId(ulong clientId), this method show me how to match lobby’s playerId to ClientId

finally, it goes to SetupClientConnectionAsync(), looks like it is same as SetPlayerIdClientRpc(playerId, clientId), both way is client sending their PlayerId to server, i am a little confused, is this safe?