Matchmaking - PlayFab
- Player starts out in an "offline" scene (that pulls data from Steam API, our APIs, leaderboards, etc.) where they can configure settings, check out the store, configure their loadout/settings, etc.
- They can invite friends into a lobby (using Steam API)
- None of this needs Mirror (not connected to a server yet, just making API calls)
Sample matchmaking flow:
- Invite up to 7 other friends into lobby (using Steam API?)
- Optionally promote someone else in the lobby to leader
- Leader clicks Play → display matchmaking details on UI
- Client sends request to matchmaking API → returns an IP
- Client sets NetworkManager.networkAddress and calls NetworkManager.StartClient()
- Players join game scene (in lobby zone). Server spawns LobbyPlayer Prefabs (set as the Player Prefab on NetworkManager) for all players initially.
- Players can select class and loadout, which sends NetworkMessages to the NetworkManager, which stores a Map<Player, PlayerLoadout?>.
- When game timer is at 0 and there are enough players, the game starts:
- For all players, server calls NetworkServer.ReplacePlayerForConnection() with the respective prefab (depending on player class/loadout from Map<Player, PlayerLoadout>)
- Server instantiates these players at the appropriate spawn locations
- Upon death, display in-game class-selection menu (but monsters this time), update Map<Player, PlayerLoadout> and upon selection, call NetworkServer.ReplacePlayerForConnection() based on the player's choice
- When the game ends, server calls backend services to update player gold, leaderboards, game statistics/details, player statistics, etc.
- All players disconnect (use NetworkServer.disconnect() perhaps) and join a client menu scene that pulls data from backend services (for updated stats, etc.)
- There is no need for NetworkRoomManager/NetworkRoomPlayer. Those wouldn't work anyways, since all players need to be present + ready (which doesn't make sense in matchmaking context). Instead, just use matchmaking API to fetch game ID, join game manually (and for dev builds, include option to connect by ID).