Tutorial: a working multiplayer menu
What you are building
The plan, the assets you need, and what each one is for. Start here if you have never built multiplayer in Unreal.
Every other page in these docs explains one feature. This section is different. It goes from an empty project to two players in the same match, in order, assuming nothing.
If you have built Unreal multiplayer before, skip ahead to Sessions.
What you will have at the end
A menu with four controls that work:
- Host creates a session other players can find.
- Find searches, and lists what it found.
- Join enters the one you selected.
- Start sends everyone into the match together.
What you will create
Five assets: two levels, and three Blueprint classes that do the work.
| Asset | Parent class | Its job here |
|---|---|---|
L_Menu and L_Match | Level | The menu screen, and the place the match happens |
BP_MenuGameMode | Game Mode Base | Tells L_Menu which Player Controller to use |
BP_MenuController | Player Controller | Creates the menu and owns it |
WBP_MainMenu | User Widget | The menu itself. Every SteamForge node goes in its graph. |
Why two levels, and what survives
When the host starts the match, the game changes level. Unreal calls this travel, and it throws away more than people expect:
| Destroyed on travel | Survives travel |
|---|---|
| Your menu widget | Every SteamForge subsystem |
| The Player Controller that created it | The Game Instance |
| Every actor in the level |
That is why the menu and the match are separate levels rather than one.
It is also why this tutorial never creates a Game Instance. The session state you care about is already in a subsystem, which outlives travel on its own. After the match starts, Is In Session, Is Session Host and Get Session Settings all still answer correctly, with nothing carried across by you.
You would only add a Game Instance of your own if you had state of your own to keep, like which character the player picked before the match started.
How hosting actually works
There is no server computer here. The host is one of the players, running the game and accepting connections at the same time. Unreal calls that a listen server, and it is what nearly every small co-op game uses.
So "starting the match" is three separate things happening in order:
- The host changes to the match level and starts listening for connections.
- The host publishes the address it is listening on into the Steam lobby.
- Everyone else reads that address and connects to it.
SteamForge does all three. It is still worth knowing they are distinct, because when multiplayer misbehaves it is almost always one of these three that did not happen.
Lobby, session, match
Three words that get used loosely. Here they mean specific things.
| Word | What it means |
|---|---|
| Lobby | Steam's meeting room. A list of players and some key/value data. No game running. |
| Session | A lobby with SteamForge's agreed data on it: name, map, player count, password. Still no game running. |
| Match | The actual game, after travel, with everyone connected to the host. |
Players gather in a session, then travel into a match. This tutorial builds both halves.
Before you start
Work through Installation and First steps first. Specifically, steam.Status must report Available: yes, whether through mock mode or real Steam. Nothing below works if it does not.