In this post we're going to add Achievements to the Third Person Template project we…
Integrating Steam SDK – Part 1
In this post we’re going to integrate Steam into the Third Person C++ Project Template that comes with UE4. The end result is shown in the picture above.
Requirements
In order to integrate Steam in your game, you need to download the Steamworks SDK and have steam as a client, installed in your PC. Keep in mind that you can integrate the required SDK even if your game is not officially greenlit yet. Steam provides a sample game, named Spacewars which contains all the features offered in its SDK. In the end result, Steam is going to recognize your game as Spacewars. This post was written in 4.14 version, in case you’re using a different version of the engine the following workflow might differ a bit.
Please note that in 4.14 version of the engine, Steamworks 1.32 is included. You don’t have to download the latest SDK if that version offers all the required features you wish to include in your game.
Modifying your engine – Skip this step if you’re using the included Steamworks version
Once you have the latest Steamworks SDK, copy and paste the “sdk” folder in the following path:
[Your_EpicGames_Path]\Engine\Source\ThirdParty\Steamworks\Steamv132and rename the Steamv132 to SteamvXXX where XXX equals the latest SDK number. Then, open up the Steamworks.build.cs file which is located in the following path:
[Your_EpicGames_Path]\Engine\Source\ThirdParty\Steamworks\and make sure to edit the following line to match your current version:
1 2 |
/** Mark the current version of the Steam SDK */ string SteamVersion = "vXXX"; //XXX equals your current SDK version |
Adding the necessary Binaries
At this point, you need to add certain binaries to our engine. To do that, go to [Your_EpicGames_Path]/Engine/Binaries/ThirdParty/Steamworks/SteamvXXX and you will notice that there are two folders, named Win64, Win32. We need to add certain binaries in each folder.
Inside Win64, add the following files:
- steam_api64.dll (in case you’re using an updated Steamworks SDK – this file is included inside the redistributable_bin folder that is located inside the sdk folder you’ve downloaded through steam)
- steamclient64.dll (this file is located inside your steam’s client installation folder)
- tier0_s64.dll (this file is located inside your steam’s client installation folder)
- vstdlib_s64.dll (this file is located inside your steam’s client installation folder)
Inside Win32, add the following files:
- steam_api.dll (in case you’re using an updated Steamworks SDK – this file is included inside the redistributable_bin folder that is located inside the sdk folder you’ve downloaded through steam)
- steamclient.dll (this file is located inside your steam’s client installation folder)
- tier0_s.dll (this file is located inside your steam’s client installation folder)
- vstdlib_s.dll (this file is located inside your steam’s client installation folder)
Adding Steam support in your game
At this point, you’re ready to add Steam support in your game. To do that, open up the [YourProjectName].Build.cs file and add the following code:
1 2 3 |
PublicDependencyModuleNames.AddRange(new string[] { "OnlineSubsystem", "OnlineSubsystemUtils" }); DynamicallyLoadedModuleNames.Add("OnlineSubsystemSteam"); |
Then, inside [YourProjectName].Target.cs file, tell your project that you’re using steam:
1 2 3 4 5 |
public SteamIntegrationTutTarget(TargetInfo Target) { Type = TargetType.Game; bUsesSteam = true; } |
The last thing we need is to add specific settings to DefaultEngine.ini which is located inside the Config folder of your project:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
[/Script/Engine.Engine] !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 |
At this point, to test your game’s Steam functionality, you can either enable the Online Subsystem Steam plugin (found in Online Platform category) from within the editor and launch a Standalone version of your game or you can package your game and then try playing. Please note that in both cases, you need to be logged into your Steam account.
In any case, Steam will detect that you’re play Spacewar (since we used Spacewar’s DevAppId for this project) overlay by pressing Shift + Tab:
In the next part, we’re going to integrate Steam Achievements in our game too, so stay tuned!
For all those getting errors with version 1.3.8 of the SDK, it has build errors. Simply revert to v132 provided with engine version 4.14 and all will work.
Hi
I saw that your post, it was very nice.
I want to setup with SDK(v139), but it has build errors..
Have you try it?
139 also has build errors, since I overwrote the one that came with the engine…. I downloaded 132 from https://partner.steamgames.com/downloads/list and it worked finally.