Integrating PlayFab Back End Service into Unreal Engine

Introduction:

I was looking around for a while on how to properly integrate PlayFab into Unreal Engine. After trying the PlayFab C++ SDK, with little luck as my c++ skills need work, I found Ufna’s VaRest plugin. What a godsend. I used his JsonObject and JsonValueObjects but completely revamped the calls. With this plugin you can use one node to make the request and get back a response when it is received. Below is how to set it up and use it.

Installation:

To install the plugin, download the development fork from HERE.

Next, copy the contents into <Game>/Plugins/PlayFab. You will need a c++ game for now. Next go to your uproject file, right click and select “Generate Visual Studio Files”. Then open up the visual studio project file and move into “Setup”.

Setup:

To use the PlayFab plugin you need to have an account with PlayFab, setup your title and have AppIds for that Title. You can find out all about that process HERE.

Navigate to the c++ file located in “Games/<Project>/Plugins/PlayFab/Source/PlayFab/Private/PlayFabRequestProxy.cpp”. Next open the file and near the top there are 7 FStrings that need to be updated to match your AppId.

  1. Change the <AppId> text in the URL to match your AppId.
  2. Chage the <AppId> to match your AppId.
  3. Input your AppId between " ".
  4. Input your secret key between " ".
  5. If you are using the photon services through PlayFab enter the corresponding AppId between " ".
  6. If you are using the photon services through PlayFab enter the corresponding AppId between " ".
  7. If you are using the photon services through PlayFab enter the corresponding AppId between " ".

Here is a picture of the code.

You are finished with the setup now rebuild your game and open up the Editor.

Demo:

To use the plugin all you do is drag an API call onto your Event Graph. The API calls can be found under PlayFab and then either Client or Server as can seen in the image below.

Attach the node to an event, pass in the required variables and then attach whatever you want to handle the response up to the graph like below.

That is all it takes! The PlayFab nodes will send out the API call, wait for a response and pass back the response from the PlayFab servers. Take a look at their documentation to see what each API call returns and expects.

I hope this helps anyone interested in using the awesome services provided by PlayFab.

  • Josh

Hey Josh,
Great work! Just trying out playfab myself and this is great you put this together! hope to test it bit more soon

Good to hear it! The playfab and photon combo is great if used together. I just got play fab and the photon chat system up and running. The great thing about play fab is they have photon integrated if you have the higher tiers.

nice i was waiting for some playfab integration!! great job

Good job! :slight_smile:

Hi,
this plugin looks great, however I got an error. I am not familiar with C++ so I can’t fix it right now.

When I try to generate the Visual Studio Files I got the error that says:
“\PlayFab.Build.cs(19,16) : error CS1520: Die Methode muss einen R?ckgabetyp besitzen.” (The Method need to have a return value).

Thx for your advice,

Hi , i am getting same error as HendrikE

"PlayFab.Build.cs(19,16): error CS1520: Yöntemin bir dönüş türü olmalıdır " (The method need to have a return value)

Edit:
Fixing it easy

rename the function to “PlayFab”
public PlayFab(TargetInfo Target)

Yeah i had fixed it this way too, but now I can’t perform any actions. When I try to register an account it’s allways returns code: 500 (which means no JSON format).

Let me take a look at it and see what the issue is. It works in my game but I could have it setup slightly different. I apologize for the inconvenience.

Updated the plugin with a couple of fixes that I was using with my game. Code 500 could also mean that you were sending the wrong parameters. If you get anything other than code 200 Play Fab sends error codes and the reason back to you. Read out all your responses using a print node with encode hooked to the response object and see what the error is telling you.

  • Josh

Hey man,
everything works now. I am so happy! :smiley:
I send you a PM, read it!