Set up Steam sessions in MPSurvival¶
After this guide, players host and find games through Steam. The server list shows the Steam name of the host, and players connect through Steam, with no port to open on the router.
MPSurvival hosts, finds and joins games with the engine session nodes in BP_SurvivalInstance: Create Session, Find Sessions, Join Session and Destroy Session. These nodes talk to Steam as soon as the Steam online subsystem is on, so no graph changes.
Before you start¶
- MPSurvival in Unreal Engine 5.5, with the main menu map
MAP_MainMenu. - The Steam client, installed, running and logged in.
- To test a join: a second PC with a second Steam account. A Steam account cannot join its own game.
Turn the plugins on¶
- Open MPSurvival.
- Open Edit, then Plugins.
- Type
Online Subsystem Steamin the search box, and tick its box. - Type
Steam Socketsin the search box, and tick its box. - Close the editor. Do not open it again yet.
Steam Sockets carries the network driver that connects players through Steam.
Tell Unreal to use Steam¶
- Open
Config/DefaultEngine.iniin a text editor. -
Add these lines at the end of the file:
[/Script/Engine.GameEngine] !NetDriverDefinitions=ClearArray +NetDriverDefinitions=(DefName="GameNetDriver",DriverClassName="/Script/SteamSockets.SteamSocketsNetDriver",DriverClassNameFallback="/Script/OnlineSubsystemUtils.IpNetDriver") +NetDriverDefinitions=(DefName="DemoNetDriver",DriverClassName="/Script/Engine.DemoNetDriver",DriverClassNameFallback="/Script/Engine.DemoNetDriver") [OnlineSubsystem] DefaultPlatformService=Steam [OnlineSubsystemSteam] bEnabled=true SteamDevAppId=480 bInitServerOnClient=true -
Save the file, then open MPSurvival again.
| Line | Why |
|---|---|
!NetDriverDefinitions=ClearArray |
Removes the network driver that the engine declares by default. Unreal uses the first driver it finds, so without this line it ignores the Steam driver |
SteamSocketsNetDriver |
Players connect through Steam, to a Steam ID |
IpNetDriver |
The fallback. Steam does not start in Play In Editor, so the editor keeps playing over IP |
DefaultPlatformService=Steam |
Sessions go through Steam instead of the default online subsystem |
SteamDevAppId=480 |
Spacewar, the test app that Valve shares with every developer. Use your own app ID before you release the game |
bInitServerOnClient=true |
Lets a player host a game. Without it, Host Game fails |
Search the internet, not the local network¶
BP_SurvivalInstance hosts and searches on the local network by default, because the default online subsystem only works there.
- Open
Content/MPSurvival/Blueprints/PlayerCharacter/BP_SurvivalInstance. - Click Class Defaults in the toolbar.
- In Details, open Settings, then Session.
- Untick
Use LAN. - Click Compile, then Save.
Check that it works¶
Steam does not start in Play In Editor. Test in a standalone game or in a packaged build.
- Open
MAP_MainMenu. A standalone game starts on the map that is open in the editor. - Open the menu next to Play, and pick Standalone Game.
- Check that the Steam overlay message shows in a corner of the game window.
- Click Host Game, set
Max Players, then click Start. - On the second PC, with the second Steam account, start the game the same way.
- Click Find Games. The game of the host shows with the Steam name of the host.
- Click the row to join.
If it does not work¶
| What you see | What to check |
|---|---|
| No Steam overlay message | The Steam client runs and is logged in. Online Subsystem Steam is ticked in Plugins |
The game starts on MAP_Showcase, not on the menu |
A standalone game starts on the map that is open in the editor. Open MAP_MainMenu first |
Find Games shows No games found. |
Use LAN is unticked in BP_SurvivalInstance. With the test app 480, Steam lists only the games of your own region |
Host Game shows Could not host a game. |
bInitServerOnClient=true is in DefaultEngine.ini |