I cannot figure out how to do this. Currently what I am wanting to do is as follows: I have a screen where player 1 can pick a character and customize it, and three others can press A to join and customize their own characters. When they are all ready, these four character customizations host or join a server, where playerobjects are spawned for them and their customization options are applied to their playerobjects.
That is, the players all join, and then they are added to the server. When I try to use ClientScene.addplayer, though, it says I need a connection. Do I need to already be hosting or joining a server to add multiple local players?
I understand the concept of transferring data between scenes - it’s the multiple local players going online that has me confused. If the sample project has that feature, I cannot find it.
I really cannot see how the hook has anything to do with multiple local players joining an online match. It looks like it is only for transferring traits from a lobby prefab to an in game prefab?
Add a LobbyPlayer object for each player, using ClientScene.AddPlayer() (for example, this can driven by pressing controller buttons for local players)
Remote players can also connect at this time and add players
every hits their “ready” button
The game switches to the game-play scene
OnLobbyServerSceneLoadedForPlayer is called on the server for each player (local and remote)
The existing NetworkLobby doesn’t really support joining games in progress, it requires everyone to be in the lobby when the game starts. The regular NetworkManager supports join-in-progress though.
Ah, okay. I did notice that AddPlayer() requires an established connection, which is why you starthost first. But what if I want to have a party of local players join as a client? Can I have everybody locally join, and then have that party join a game hosted elsewhere?
[EDIT]
I am using a standard NetworkManager, too, implementing a custom lobby system instead
There is nothing built-in to the NetworkManager to do that. You’d just have to have them all join the remote game and call AddPlayer() once a connection was made to it. So there would be a local, offline, “Pre-lobby”? Probably the same thing would work for both local and remote games.
Thanks. Okay, I have the server creating the correct number of players. But how do I transfer the data from the client scene to the server scene? I have the client call AddPlayer() for each local player, but the server at that point doesn’t know what options the client had select when it’s creating its player with AddPlayerForConnection().
[edit]
I guess I should just change my code so that the items the players select are stored by string and then can be synced to the server, rather than stored by reference
One the players are connected to the server, they can send commands to choose their items. If the items are SyncVars or SyncLists on the server, then other players (even remote ones) will see the item choices of the players.