Getting in Game #
In this section, we’ll put the finishing touches by generating our tokens via the Pragma Portal. Then we’ll test our work by building and packaging our game server and client, then going through matchmaking and getting into game. We’ll first start the platform up so that we can access the portal to generate our tokens.
Start Pragma Engine #
Run Pragma Engine via one of the following methods.
Once the engine has started successfully, it prints the message [main] INFO main - Pragma server startup complete
.
Generate the Social and Game tokens #
For the game server to integrate with the Pragma Engine backend, we need to generate tokens.
- Using a terminal from your Pragma Engine’s platform directory, run
make portal-start
. - When you see the development and test server start, open a browser and navigate to
localhost:3000
, then log in to the Portal via unsafe login using the account test01. - Click on the Services menu, then Game Server Management.
- Select the testGameShard game shard, then click the Create Tokens button to generate tokens.
- In your
PragmaGameServer.h
file, paste in the tokens you just generated.FString SOCIAL_TOKEN = "Social token value here";
FString GAME_TOKEN = "Game token value here";
Set the default map for the game server #
We now need to configure the default map for the game server. This is the map we created earlier during this tutorial.
- Switch to Unreal Editor.
- From the Edit menu, click Project Settings.
- In the Project Settings window, click Maps & Modes which is under the Project category.
- Expand the Default Maps section.
- Ensure that the Editor Startup Map and Game Default Map both still point to level where you built out your game’s login and party screen. You likely do not need to make any changes here.
- Ensure that the Server Default Map points to ServerMap, which you created earlier during this guide.
- Don’t close the Project Settings window yet.
Include maps in packaged build #
Next, we need to ensure that those maps get included when we package our standalone dedicated server.
- In the sidebar, click Packaging, which is also under the Project section.
- Under List of maps to include in a packaged build, include both the ServerMap and the map where you built the login and party screens.
Package the server and client #
- In Unreal Editor, go to the File menu, Package Project, Build Target, and select the game client.
- Go to the File menu, Package Project, Windows (64-bit), and select a convenient directory.
- When the build finishes, go back to the File menu, Package Project, Build Target, and select the game server.
- Go to the File menu, Package Project, Windows (64-bit), and select the same directory.
- When this build finishes, you should now have standalone client and server executables built and packaged.
Configure the Local Process Capacity Provider #
Lastly, we need to configure Pragma Engine to launch our game executable.
- Open or switch to IntelliJ, then open your copy of
pragma-engine
. - Navigate to your
5-ext/config/local-dev.yml
file. - Insert the following configuration:
game:
pluginConfigs:
MatchCapacityService.capacityProvider:
class: "pragma.matchcapacity.LocalProcessCapacityProvider"
config:
processCommand:
0: "C:/Path/To/TutorialsServer.exe"
1: -pragmaBackendAddress="http://127.0.0.1:10100"
2: -hostname="127.0.0.1" # Passed to client via HostConnectionDetails
3: -port=7777 # Passed to client via HostConnectionDetails
4: -version="GameServerVersion1"
5: -pragmaServerNoExit # Don't exit when done.
serverIdParam: -serverID=
gameServerZoneParam: -gameServerZone=
logPathParam: ""
logOutputPath: ""
maximumLocalServers: 1
You should modify the following line to point to the game server executable that you just packaged: 0: "C:/Path/To/TutorialsServer.exe"
4. If pragma-engine
is currently running, stop and restart it.
Get in game #
- Launch two copies of the game client executable.
- Log into each client with test01 and test02.
- Proceed through the party screen then start matchmaking on both clients.
- After matchmaking succeeds, the Pragma Engine backend launches the game server, which calls connect players. Connection details get sent to the game clients, which then connect to the game server to play the game.