Tutorial: a working multiplayer menu
Step 3: Find and join
List the sessions that exist and join the one the player picked.
Hosting is half of it. Now the other side: finding a session and getting into it.
Store the results
Searching gives you an array of results. A dropdown holds only text, so you need to keep the real results somewhere in order to look up what the player picked.
- In the Variables panel, click + to add a variable.
- Name it
FoundSessions. - Set its type to Steam Session Search Result.
- Click the icon beside the type and change it from a single value to an Array.
Compile.
Wire the Find button
Add an On Clicked event for Button_Find, the same way you did for Host.
From its execution pin, add Find Sessions and leave Max Results at its default.
From the node's On Success pin:
- Add Set Found Sessions, connecting the node's Sessions output into it. The results are now saved.
- Drag in
Combo_Sessionsand add Clear Options, so a second search does not stack on top of the first. - Add a For Each Loop and connect the Sessions array to its Array pin.
Inside the loop body:
- Drag off Array Element and add Break Steam Session Search Result.
- Add an Append node and build a readable line from Session Name, a space, Current Players, a slash, and Max Players.
- Drag in
Combo_Sessionsagain, add Add Option, and feed the appended text into it.
Wire the Join button
Add an On Clicked event for Button_Join.
The dropdown knows which row is selected, and row order matches array order, so the index is the link between the two.
- Drag in
Combo_Sessionsand add Get Selected Index. - Drag in
FoundSessionsand add Get (a copy), feeding the selected index into its index pin. - Drag off that and add Break Steam Session Search Result.
- From the button's execution pin, add Join Session.
- Connect the Lobby field from the break node into Join Session's Session pin.
Leave Password empty. Leave Travel ticked this time. That covers both cases: if the host has already started, joining takes you straight into the match, and if they have not, this client follows them automatically the moment they do. Untick it only if you want to handle the travel yourself.
Report the outcome
Join Session reports a Diagnosis on both output pins rather than a bare true or false. Use it.
- From On Failure, drag off Diagnosis and add Break Steam Join Diagnosis.
- Feed its Player Message field into Set Text on
Text_Status.
That field is already written for a player to read: wrong password, session full, different version, and so on. There is nothing for you to translate.
From On Success, set the status to Joined.
Compile and save.
What you can check alone
Press Play, click Host, then click Find. Your own session should appear in the dropdown.
That proves hosting and searching work. It does not prove joining works, because you cannot join yourself. For that you need two players, which is the next page.