Improbable Icon


Unreal, Spatial OS and Playfab


I know there is a nice guide connecting Unity, Spatial OS and Playfab. When could we expect one for Unreal?


I’m using the SpatialOS form of Unreal Engine v4.20.3:

I’m currently working on this, so I thought I’d share what I’ve done. The PlayFab plugin won’t currently install from the marketplace. To get around this, I installed a clean v4.20.3 of the non-SpatialOS engine, and then installed the PlayFab plugin into that engine. I then grabbed the Marketplace/Plugins folder from that engine and copied it into the UnrealEngine\Engine\Plugins folder of my SpatialOS fork build from source. I opened the SpatialOS fork in Visual Studio, and rebuilt the UE4 project. This results in an error: not all of the PlayFab blueprints in the current plugin have their category set.

In PlayFabAuthenticationContext.h @ 147, you’ll see this:

void ForgetAllCredentials()...

You need to add the BluePrint category. Mark the function so that the whole thing looks like this:
// Reset all fields **UFUNCTION(BlueprintCallable, Category = "PlayFab | Core")** void ForgetAllCredentials() { ClientSessionTicket.Empty(); EntityToken.Empty(); DeveloperSecretKey.Empty(); PlayFabId.Empty(); }

Now rebuild your source engine. When that’s done, go back to your project that references the SpatialOS source built engine, and you’ll be able to use the PlayFab plugin in your project.


Using the above, I was able to get this to work:

For testing, you’ll have to put in an e-mail registered with PlayFab and your password.


I’m using the ThirdPersonExample starter from the SpatialOS documentation. (not the third person shooter)

The next piece I’m working on is to present clients with a login screen (spoiler, I’m currently stuck).
I created a map to present the login screen, along with a new GameMode and an empty Pawn. I set the default pawn of the new game mode to the new Pawn. I created a login widget with a button that fires the above code. On the pawn, I set up the OnBeginPlay event to attach the new widget to the user’s viewport. I then changed the default GameMode for the project to the new GameMode, and the default map to the new map.
I then set the GameModeOverride of the ThirdPersonExampleMap to the SpatialOS game mode created with the project.

Currently, the client will start up, briefly load connect to the login screen, but then immediately travel to the connected map and load that. The UnrealWorker appears to correctly start on the online map.

Could someone point me in the right direction here: how should I stop the client from connecting immediately?

I’m trying a slightly different approach than outlined above: I’m experimenting with allowing the client to connect to the deployment automatically, and then having a worker handle login for the player controller. Basically, on connect the client’s input mode is set to “UI Only,” and then the UI initiates an RPC to the worker on the client’s player controller which then contacts the PlayFab login server and relays the response back to the client. On success, the auth token is attached to the worker’s representation of the controller. On failure, the client is alerted with the failure message.

This works well in the editor, but I’m seeing strange behavior when deployed.

On login, first the worker logs this:
[Worker: UnrealWorker2] Tried to trigger BeginPlay twice! This should never happen -[WorkerLogger:Unreal]

Then a few ms later, it logs this:

[Worker: UnrealClient-6116845799079936-d8b3a33b-f6f5-4687-97fc-bf65c6fc81df] DoServerLogin: failed too many times, giving up (5 attempts). Error code: 4 Message: Authority moved during delivery -[WorkerLogger:Unreal]

I also noticed this in the logs (Client):
[Worker: UnrealClient-6116845799079936-d8b3a33b-f6f5-4687-97fc-bf65c6fc81df] Object ref did not map to valid object, will be set to nullptr: (entity ID: 0, offset: 0) ./Game/StarterProject/Modes/ExtGameMode.ExtGameMode_C -[WorkerLogger:Unreal]

What’s interesting to me is that this doesn’t happen locally - I only see it when connecting to a deployment.

Just to be clear, the login flow is this:

On the widget:
Client: OnClicked -> DoServerLogin (RELIABLE Replicated to Server is owning client)
Target is ExtPlayerController (base class is the PlayerController provided in the example project)

On ExtPlayerController:
DoServerLogin -> SetPlayFabSettings (title id only) -> LoginWithEmailAddress -> OnSuccess -> LoginComplete (on ExtPlayerController - Target is ExtPlayerController replicated to owning client (if server))

On ExtPlayerController:
LoginComplete -> sets the input mode back to game + UI, grabs a reference to the widget container that hold the login background and controls and collapses them.

Here are my BPs: