UE4 and Steam Rich Presence

NOTE: If you're wanting a Steam wrapper for UE4 then check out SteamBridge. If you use SteamBridge it already has the code below so you won't need to do any code portion of this guide.

 

So you're wanting some cool Rich Presence for your game right?

 

Cool so here's a quick guide on doing this in C++ in UE4. (don't worry, the methods are exposed to BP)

 

  1. Go to your projects Build.cs and add Steamworks. PrivateDependencyModuleNames.AddRange(new string[] { "Steamworks" });
  2. Regenerate your project and open your solution. Add the following code to whatever class you want. I chose to do this in the GameInstance as it exists for the lifetime of the game.
    UFUNCTION(BlueprintCallable, Category = "GameInstance")
    
    void SetSteamRichPresence(const FString& Key, const FString& Value);
    
    

    UFUNCTION(BlueprintCallable, Category = “GameInstance”) void ClearSteamRichPresence();

    // At the time of writing this sdk version 150 is released, but UE4 only has 147. This doesn’t matter, but just a note. #include “ThirdParty/Steamworks/Steamv147/sdk/public/steam/steam_api.h”

    void UCGameInstance::SetSteamRichPresence(const FString& Key, const FString& Value) { SteamFriends()->SetRichPresence(TCHAR_TO_UTF8(*Key), TCHAR_TO_UTF8(*Value)); } void UCGameInstance::ClearSteamRichPresence() { SteamFriends()->ClearRichPresence(); }

  3. Before you can go off and do what I did above you should know that you have to make a json file with the strings that can be set. Yeah, the messages have to be uploaded to Steam. 🙁
  4. Head over to Steam to view more details on doing this, but I'll show you a quick breakdown.
  5. Sign into Steam's Partner site, then navigate to Steamworks settings, and then under Community select Rich Presence.


  6. Here's a short example of a localization file for rich presence. (See this page to understand how it works)
    "lang"
    
    {
    
    	"english"
    
    	{
    
    		"tokens"
    
    		{
    
    			"#Status_AtMainMenu"	"At the main menu"
    
    			"#Status_WaitingForMatch"	"Waiting for match"
    
    			"#Status_Winning"	"Winning"
    
    			"#Status_Losing"	"Losing"
    
    			"#Status_Tied"	"Tied"
    
    			"#Status_JoiningMatch"	"Joining a match"
    
    			"#Status_InAParty"	"In a party"
    
    		}
    
        }
    
    }
  7. Here's how it looks.
     
  8. Congrats you've added Steam Rich Presence to your project!

 

until next time