Steam, Using the Steam SDK During Development

From Epic Wiki

Overview

Original Author: Rama

Dear Community,

This is my guide to getting Steamworks running with your game!

You do not need to have been Greenlit to start using the Steam SDK during your game's development process.

Steamworks SDK

(in 4.7 and beyond you dont need to do this step, you will find the Steam binaries in Engine/Binaries/ThirdParty/Steamworks)

Download the steamworks SDK:

Steamworks SDK

Identify what the latest version is that you are downloading, such as "v129a"

Github Engine Builds vs Retail UE4 Builds

Please note that recompiling the engine and modifying the Steamworks build cs is not required.

If you are not using your own locally built verison of the engine you should be able to simply download the Steam SDK and skip to this step:

Retail Builds Skip to This Step

Binaries, DLL copying

Engine/Source/ThirdParty/Steamworks

Copy the entire contents of the downloaded SDK to

 Engine/Source/ThirdParty/Steamworks/Steamv129a
 
or whatever your current version is!

So you will end up with folder structure like this

 Engine/Source/ThirdParty/Steamworks/Steamv129a/sdk/

Steam Build CS

Open the Steam Build CS contained in the directory structure

 Engine/Source/ThirdParty/Steamworks/

Make sure the version number there matches the version you downloaded as the Steam SDK!


Engine/Binaries/ThirdParty/Steamworks

Now in your UE4 engine's Binaries folder you must create this directory structure

 Engine/Binaries/ThirdParty/Steamworks/Steamv129a/Win64
 Engine/Binaries/ThirdParty/Steamworks/Steamv129a/Win32

Remember to use your current steam version as shown in the SDK you downloaded!

Dll Files

Dlls marked with ( Steam Client Install Dir ) are found in your program files x86 / Steam directory (regular steam client)

The other 2 dlls are found in the SDK you downloaded in this directory structure

 sdk/redistributable_bin

Win64

 steam_api64.dll	(Downloaded SDK)
 steamclient64.dll 	(Steam Client Install Dir)
 tier0_s64.dll		(Steam Client Install Dir)
 vstdlib_s64.dll 	(Steam Client Install Dir)

Win32

 steam_api.dll		(Downloaded SDK)
 steamclient.dll 	(Steam Client Install Dir)
 tier0_s.dll  		(Steam Client Install Dir)
 vstdlib_s.dll  	(Steam Client Install Dir)

Build.CS

In your game's build.cs you need to include this:


 PublicDependencyModuleNames.AddRange(new string[] { 
 	"OnlineSubsystem",
 	"OnlineSubsystemUtils"
 });
 DynamicallyLoadedModuleNames.Add("OnlineSubsystemSteam");

Target.cs

In your game's Target.cs, add bUsesSteam=true in the constructor. Here's an example:

public class ShooterGameTarget : TargetRules
{
    public ShooterGameTarget(TargetInfo Target)
    {
        Type = TargetType.Game;
        bUsesSteam = true;
    }
    .....

Config/DefaultEngine.ini

[/Script/Engine.GameEngine]
!NetDriverDefinitions=ClearArray
+NetDriverDefinitions=(DefName="GameNetDriver",DriverClassName="/Script/OnlineSubsystemSteam.SteamNetDriver",DriverClassNameFallback="/Script/OnlineSubsystemUtils.IpNetDriver")

[OnlineSubsystem]
DefaultPlatformService=Steam
PollingIntervalInMs=20

[OnlineSubsystemSteam]
bEnabled=true
SteamDevAppId=480
GameServerQueryPort=27015
bRelaunchInSteam=false
GameVersion=1.0.0.0
bVACEnabled=1
bAllowP2PPacketRelay=true
P2PConnectionTimeout=90

[/Script/OnlineSubsystemSteam.SteamNetDriver]
NetConnectionClassName="/Script/OnlineSubsystemSteam.SteamNetConnection"

WinPlatform.Automation.cs

In Visual Studio, this file is in the folder Programs/Automation/Win.Automation/WinPlatform.Automation.cs . Open it, and check that this string has your Steam API version:

 string SteamVersion = "Steamv131";

OnlineSubsystemPlugin

>Edit from Rumbleball 29.03.2018

This Wiki entry seems to be pretty old and there seems to be some changes to the engine. UE4.16+ (at least) you will need to enable the OnlinesubSystemSteam Plugin for your game. If you don't do that, you will get the following warnings in the output window of the editor:

 LogModuleManager:Warning: No filename provided for module OnlineSubsystemSteam
 LogModuleManager:Warning: ModuleManager: Unable to load module 'OnlineSubsystemSteam' because the file 'D:/Programs/Epic Games/4.13/Engine/Binaries/Win64/' was not found.

To enable the plugin: Open the editor and go to Edit->Plugins->Online Platform and enable 'Online Subsystem Steam'

Some Tips

1. There is an awesome program written by a community member named Garner. Check it out here:

Steam Setup Utility by Garner

2. Trying to run your game in PIE mode may give you a "Steam API disabled!" Error. Run your game in standalone mode to see if things get better.

Epic Tutorial

Epic's tutorial on this subject is here:

Online Subsystem Steam

Packaging

(This is not required in more recent engine builds, just check the ThirdParty folder to make sure Steam is there)

When packaging your game you must copy the Steam binaries from the engine ThirdParty to your packaged game Engine/ThirdParty

Engine/Binaries/ThirdParty/Steamworks

Packaging w/ Steam for Shipping Builds

For shipping builds you must manually create a file called:

steam_appid.txt

and in that file put just your app id with no extra whitespaces (spaces or returns or anything like that)

to test you could create such a file and put just 480 in it.

♥ Rama

Running Steam on Mac

Quoting Epic tutorial:

Contrary to Windows, Steam Overlay on Mac requires game to be launched using 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. [1]

Conclusion

If everything works you will see the steam pop up appear in the lower right and you can press SHIFT+TAB to see the Steam overlay!

If you see in your log that the .dlls can't be found, check two things

1. You put them in Binaries not Source

2. and you named the folder appropriately for your version number, ex:

 Binaries/ThirdParty/Steamworks/Steamv129

Enjoy!

( )