Choose your operating system:
Windows
macOS
Linux
Contributors: Valve
The Online Subsystem Steam API enables you to ship Unreal Engine 4 (UE4) applications to Valve's Steam platform . The main purpose of the Steam module is to help you distribute your application with a set of features (such as matchmaking and leaderboards) to Steam users. Additionally, the Steam module implements several of the interfaces being exposed by the Online Subsystem , supporting most of what is offered by the Steamworks Software Development Kit (SDK).
Some of the available Steam Interfaces include:
-
Matchmaking (Lobbies and GameServer APIs)
-
Leaderboards
-
Achievements
-
Voice
-
UserCloud
-
SharedCloud
-
External UI
Reference our Online Subsystem Steam API Reference for a more complete listing of currently available Steam Interfaces.
Meeting Valve's Requirements
The Steam Subsystem requires additional setup through Valve Steamworks . Please contact Valve and reference their Steamworks SDK Documentation to make sure that your application meets Valve's requirements before attempting to use Steam with UE4.
Downloading Steamworks
If your application meets Valve's requirements, go ahead and download the latest version of the
Steamworks SDK
.
The SDK needs to be unzipped and copied to
/YourUnrealEnginePath/Engine/Source/ThirdParty/Steamworks/Steam[Current Version]/sdk
If you're updating your project's Steamworks SDK, make sure to update the
[Current Version]
in your project's Steamworks path:
/YourUnrealEnginePath/Engine/Source/ThirdParty/Steamworks/
Steam[Current Version]
/sdk
You'll also need to update
Steamworks.build.cs
, which is located in the project directory.
In this example, the
[Current Version]
is formatted as
v139
.
Compiling UE4
If you're compiling Unreal Engine 4 from source , the following steps should be taken:
-
Open "OnlineSubsystemSteamPrivatePCH.h" (located in "..\..\Plugins\Online\OnlineSubsystemSteam\Source\Private\"), where you'll find the following line of code, defining the root location of the Steamworks SDK:
#define STEAM_SDK_ROOT_PATH TEXT("Binaries/ThirdParty/Steamworks")
-
You'll want to modify the line to read:
#define STEAM_SDK_VER TEXT("Steam[Current Version]")
Setting up the Steamworks SDK
Using Steam against the precompiled version of the engine should only require copying some of the dynamically linked libraries from Valve's SDK into the appropriate folders. If you intend to recompile the engine against the source, putting the SDK in the right place is required as well. Now, copy the relevant redistributable files from the
/redistributable_bin/
directory of the SDK to the following locations:
Steam App ID
All games using the Steam Online Subsystem must have a valid application ID because the Steamworks API won't initialize if it doesn't know your application's Steam App ID.
Before initializing Steam, UE4 will generate
steam_appid.txt
(during a graceful shutdown of the engine, UE4 deletes this file).
It's important to note that
steam_appid.txt
must be located in the same directory as your application's executable file because Steam will look for the text file in the current working directory.
Additionally, the file should not be included in any Steam images.
If you open
steam_appid.txt
, you'll see a
SteamDevAppId
entry, which is a field that hints your application's ID to Steam.
This makes it unnecessary to launch the game using the Steam client (although it must be running).
If you want to test your application, you can use a
SteamDevAppId
of
480
, which is a test App ID that is shared by all developers.
Although you can test most Steam Interfaces with the aforementioned test App ID, your application will need a Steam App ID before being shipped.
Shipping Builds
In shipping builds, the engine will check to make sure that the logged-in user is properly subscribed to the game and will shutdown if the engine's test returns false (this is one way to help secure the game). Additionally, using Steam DRM (see the Steamworks SDK) should further protect the game from being tampered with.
Configuring your Application's Settings
If you're creating a new project using the
Unreal Project Browser
,
Online Subsystem
settings shouldn't exist in
DefaultEngine.ini
; however, if you're modifying one of our Sample Projects, the
Online Subsystem
settings might already exist.
Now that you've set up the Steamworks SDK for your application (along with setting up the Steam App ID), you're ready to configure your application's settings to use Online Subsystem Steam.
Steps
-
Open your project's
DefaultEngine.ini
file and add the following setting:[/Script/Engine.GameEngine] +NetDriverDefinitions=(DefName="GameNetDriver",DriverClassName="OnlineSubsystemSteam.SteamNetDriver",DriverClassNameFallback="OnlineSubsystemUtils.IpNetDriver")
NetDriverDefinitions describes the net drivers available to UE4 with the following properties being defined:
-
DefName is the unique name of this net driver definition.
-
DriverClassName is the class name of the primary net driver.
-
DriverClassNameFallBack is the class name of the fallback net driver if the primary net driver class fails to initialize.
-
-
To tell UE4 to use Online Subsystem Steam, add the following setting:
[OnlineSubsystem] DefaultPlatformService=Steam
-
Now that you've told UE4 that you want your application to use the Steam Online Subsystem, you'll need to configure the OnlineSubsystemSteam module by adding the following settings:
[OnlineSubsystemSteam] bEnabled=true SteamDevAppId=480
-
Finally, you'll want to specify the Steam class to the Net Driver for the application's connections:
[/Script/OnlineSubsystemSteam.SteamNetDriver] NetConnectionClassName="OnlineSubsystemSteam.SteamNetConnection"
End Result
At the end of this brief guide, your application's
DefaultEngine.ini
file should look like the following setting block. If you want to see how other projects set up and use the Online Subsystem, please refer to our library of Sample Projects.
Finished Settings
DefaultEngine.ini
[/Script/Engine.GameEngine]
+NetDriverDefinitions=(DefName="GameNetDriver",DriverClassName="OnlineSubsystemSteam.SteamNetDriver",DriverClassNameFallback="OnlineSubsystemUtils.IpNetDriver")
[OnlineSubsystem]
DefaultPlatformService=Steam
[OnlineSubsystemSteam]
bEnabled=true
SteamDevAppId=480
[/Script/OnlineSubsystemSteam.SteamNetDriver]
NetConnectionClassName="OnlineSubsystemSteam.SteamNetConnection"
Servers and Lobbies
Steam supports peer-to-peer matchmaking (for both dedicated and listen server games) through lobbies, and provides the ability to run dedicated servers. Lobbies give users the ability to learn information about game servers, and are usually used to convey game-specific information about listen server games, such as what map or mode is being played. Users can also see the number of other users connected to a lobby without joining, through the matchmaking system. Dedicated servers are separate binaries from lobbies, as their task is to run and host the server-side portion of the game. For more information about Steam's features, implementation, or developer interface, please refer to the partner documentation on the Steam site.
Lobby Details
Lobbies are essentially chat rooms that exist as peer-to-peer instances on Steam's backend service. Unlike servers, no information about a lobby is available before joining, such as ping times or current number of other users. They are typically used for listen servers. To set up a lobby, set the
bUsesPresence
flag to
true
.
Server Details
To set up a server instance, make sure the
bUsesPresence
flag is
false
. Dedicated servers require the following three macros, and all three must match the values from Steam's dedicated server tool page, found on the partner panel. The Steam network will not show the dedicated server if these values do not match:
UE4 Macro |
Steam Name |
Description |
---|---|---|
|
|
Valve recommends that this be a build ID, although it is typical to use your AppID (as a string), or a light product name without any extra symbols. Changing this field, such as when updating your build ID, will cause Steam to ignore all active servers with the old name for matchmaking purposes, and will require you to modify your tool information in the partner backend. |
|
|
This is usually the folder name of your game, and cannot contain spaces or symbols. It is not required for this to be a folder name at all, as long as it is a name without spaces or symbols. |
|
|
Valve recommends that you set this as the full name of your product. |
|
N/A |
To launch outside of Steam in UE4 version 4.22 and higher, this macro must contain the product's Steam ID. |
In UE4 version 4.22, you can specify these values in your game's
Target.cs
file. You can also write the Steam ID into a build by defining
UE4_PROJECT_STEAMSHIPPINGID
. All build configurations require this, and you cannot launch outside of Steam without it.
For versions before 4.22, edit
OnlineSessionAsyncServerSteam.cpp
so that it contains your game's values.
For information about distributing a dedicated server build, please refer to Steam's partner documentation .
Steam Online Authentication
Steam features a special authentication system that controls access to some of the unique server-related functionality the platform offers, such as advertising servers and player counts, retrieving and reacting to ban lists (both publisher and Valve Anti-Cheat bans), and performing license checks.
Unreal Engine 4 provides the ability to interface with this functionality through the
FOnlineAuthSteam
class.
Once your application is set up to use the Steam Online Subsystem, it is ready to take advantage of these features by enabling the
SteamAuth
packet handler component.
Enabling SteamAuth
To enable SteamAuth, add the following to "DefaultEngine.ini", or to the platform-specific engine .ini file (such as "WindowsEngine.ini", "LinuxEngine.ini", or "MacEngine.ini") for each platform that is intended to support Steam Online Authentication:
[PacketHandlerComponents]
+Components=OnlineSubsystemSteam.SteamAuthComponentModuleInterface
Once enabled, the Steam Online Subsystem interface (SteamOSS) function,
GetAuthInterface
, can be used to access SteamAuth functionality.
Enabling SteamAuth will cause the application to run authentication procedures (against the Steam service) for all joining players. By default, SteamAuth will kick players who fail this check will be kicked, but this behavior can be overridden.
SteamAuth Delegates
There are two Delegates in the SteamAuth system that developers may wish to override:
OverrideFailureDelegate
and
OnAuthenticationResultDelegate
.
OverrideFailureDelegate
is called with the
FUniqueNetId
of a player when that player attempts to join the server without Steam authentication, or when that player loses Steam authentication during the session.
By default, SteamAuth will kick the player from the game.
However, if this Delegate is bound, the default behavior will be suspended, so developers will have to kick the player manually if that behavior is still desired.
OnAuthenticationResultDelegate
handles responses from Steam's authentication service, providing the
FUniqueNetId
of the player and a boolean indicating whether the authentication attempt succeeded.
Additional Notes
Using IPNetDriver
By default, UE4's Steam OSS uses Steam Networking as the default socket subsystem. In 4.22, you can disable this behavior by setting
OnlineSubsystemSteam.bUseSteamNetworking
to
false
. To do this, add the following to "DefaultEngine.ini", or to the platform-specific engine .ini file (such as "WindowsEngine.ini", "LinuxEngine.ini", or "MacEngine.ini") for each platform you support:
[OnlineSubsystemSteam]
bUseSteamNetworking=false
In versions prior to 4.22, modify
SocketSubsystemSteam.cpp
where the
RegisterSocketSubsystem
function is called and change the
bool
parameter to be
false
. You will also need to change the netdrivers in your project configuration files.
Module Setup
Make sure to include the Unreal Engine Steam module as part of your project (see
UnrealBuildTool Target Files
for additional help).
Specifically, adding the following line in the construtor for
mygame.build.cs
should be enough to make sure that the Steam module is built along with your game.
DynamicallyLoadedModuleNames.Add("OnlineSubsystemSteam");
Steam Overlay on Mac
The Steam Overlay on Mac requires launching your games through the Steam client. For this, you first need to add the game to your library using "Add a Non-Steam Game to My Library" option from Steam's "Games" menu.