So in looking up how to do this I noticed there was a lack of any sort of guide, but I was able to eventually piece the process together and figured I’d share it for those looking to do it too.
(NOTE: This tutorial assumes you already know how to integrate the Steam SDK)
Once Steam has been properly integrated, the process is actually pretty straightforward:
Firstly, go to your Player Controller, and create a String Variable, and name it what you want and make it editable (I chose Steam Player ID) and hit compile.
Now off of your Event (I chose to use “Event Begin Play”), create a Set command for your variable (Steam Player ID). Then, we need to provide the string with input, so right-click and search for “Get Player State”.
Then drag off of the Player State and “Get Player Name” (when logged into Steam this will be the Steam Username), then connect it to the “Steam Player ID” String Variable we created.
When done, it should look like this:
http://i.imgur.com/TrrkG3Yl.png?1
Now that alone is enough to provide you with a usable string of the SteamID, but it doesn’t make it usable by other blueprints. So we need to create a Blueprint Interface.
Right-click in the content browser, and select Blueprint Interface (under blueprints), and name it what you want.
Inside it, add a function and give it a Text Output (you could use a string instead and not have to convert later, but I want to use mine for a text value), and compile.
It should look something like this:
http://i.imgur.com/ZKCIqp1l.png
Now back in the Player Controller, go to Class Settings, and add the interface we just created:
You’ll now see it listed in the interfaces dropdown, below functions. (you may have to compile first, I don’t remember if I did)
Double-click on it, to open it in a new tab, Get your “SteamPlayerID” variable and convert it to a text variable and plug it into the ReturnNode, like so:
http://i.imgur.com/WhOKvWwl.png?1
From there, you can call that Interface as a message in another Blueprint, and get the value. (You’ll need to run as a “Standalone Game” with Steam active and logged in for it to work)
How about an example?
In my UMG blueprint for my menu, I’m going to use the SteamID to show who is playing on the Main Menu.
So I create the desired Text field on my UMG, and make it a variable (check the “Is Variable?” by the object name) and compile.
http://i.imgur.com/PWZDQSwl.png?1
Now in the graph, I create a Set Text command for my Text variable, and then right-click and search for the interface we created, in my case I got this:
Make the Target for that function “Get Player Controller” and connect the text output you created into the “In Text” of your Set Text command.
That may have sounded confusing, so here is what it would look like:
http://i.imgur.com/fYmL5jOl.png?1
BONUS:
Now that we’ve got the ID accessible, let’s use it in UMG to identify who the player is.
(And on the off chance the game is being played without Steam (and possibly even Internet) we will set it to use the user currently logged into the OS, like so:
http://i.imgur.com/fv4OQv3l.png
To do this, go back to your Player Controller, where we pulled the Player State and Name.
Instead of just setting the Steam Player ID, we’re going to create a Branch. Connect the False end of the Branch to the Set “Steam Player ID” variable we created previously.
Now from your Player Name variable, create a Equal To comparison for the String, and leave the lower input blank (if Steam isn’t present, then the Player Name variable will be empty by default, so this will check if that is true) then make the output of the Equal To check the condition for the Branch.
Now for the True Branch, Create a second Set “Steam Player ID”, and for it’s input, use “Get Platform User Name”.
When done it will look something like this:
http://i.imgur.com/sRc5KKQl.png
Now compare it by running the standalone game with and without Steam active!