Set Up the Unreal SDK #

This guide covers setting up and integrating the Pragma Unreal SDK. This includes downloading the Pragma SDK, integrating it into an Unreal project, and initializing it.

Download the SDK and integrate into your Unreal project #

In the Portal from the homepage, click the Unreal SDK download button.

  • Add a PragmaSDK directory under Plugins in your project. Path: .../<unreal-project>/Plugins/PragmaSDK/.
  • Unzip the contents of the download and move all items into PragmaSDK.

Configure the Pragma SDK #

This guide is based on an example Unreal project using the Third Person Unreal C++ project template. The example project is named ‘Narwhal’, update references accordingly.

  1. In Unreal, add PragmaSDK and PragmaSDKAux to the PublicDependencyModuleNames array:

Source\Narwhal\Narwhal.Build.cs

PublicDependencyModuleNames.AddRange(
    new string[] {
        // ...
        , "PragmaSDK", "PragmaSDKAux"
    }
);
  1. Add the following configuration properties.

Config\DefaultGame.ini

[/Script/PragmaSDK.PragmaSdkConfig]
BackendAddress="https://game.<game-title>.<studio-title>cloud.pragmaengine.com" ; replace with correct subdomain
GameClientVersion="DefaultGameClientVersion"
Your backend game-title and studio-title are displayed in the Portal’s subdomain.

You can enable verbose logs during integration. These can be reduced or disabled later.

Config\DefaultEngine.ini

[Core.Log]
LogPragma=VeryVerbose
  1. Build your Unreal project now that the PragmaSDK plugin is included.

Initialize the Pragma LocalPlayerSubsystem #

Pragma provides a LocalPlayerSubsystem that initializes the Pragma SDK and establishes a connection to the backend.

This code can be placed wherever it makes sense based on how the game is initialized, this example uses a PlayerController and GameModeBase.

Set up the Player Controller #

  1. If one doesn’t already exist, create a PlayerController class (eg. NarwhalPlayerController)
  2. Add the following code:

Source\Narwhal\NarwhalPlayerController.h

#pragma once

#include "CoreMinimal.h"
#include "GameFramework/PlayerController.h"
#include "PragmaPtr.h"
#include "NarwhalPlayerController.generated.h"

PRAGMA_FWD(FPlayer);

UCLASS()
class NARWHAL_API ANarwhalPlayerController : public APlayerController
{
    GENERATED_BODY()

public:
    virtual void BeginPlay() override;
    
    
private:
    Pragma::FPlayerPtr Player;
};

Source\Narwhal\NarwhalPlayerController.cpp

#include "NarwhalPlayerController.h"
#include "PragmaPlayer.h"
#include "PragmaLocalPlayerSubsystem.h"

void ANarwhalPlayerController::BeginPlay()
{
    Super::BeginPlay();
    
    const auto* Pragma = GetLocalPlayer()->GetSubsystem<UPragmaLocalPlayerSubsystem>();
    Player = Pragma->Player();
    
}
  1. If not already completed, register the PlayerController with your GameMode.

Source\Narwhal\NarwhalGameMode.cpp

#include "NarwhalPlayerController.h"

// ...

ANarwhalGameMode::ANarwhalGameMode()
{
    // ...
    PlayerControllerClass = ANarwhalPlayerController::StaticClass();
}

Recap #

You’ve downloaded the SDK and initialized the LocalPlayerSubsystem. Move this functionality to its proper lifecycle location within the game flow as needed and build out from there.

Next, we’ll demonstrate how to log in with Steam.