Adding PingCore to Your Own Game
A checklist that takes your own Netcode for GameObjects game from the two Unity packages to players joining it on a PingCore fleet.
This checklist takes your Netcode for GameObjects game onto a PingCore fleet. Each item names the Beacon Rush file that does the same job.
Run Beacon Rush on PingCore first if you can. Every panel page and window section below is one you use there.
Before you start
Unity 6 with the Linux Dedicated Server Build Support module.
A game on Netcode for GameObjects 2.x with Unity Transport.
A PingCore workspace with prepaid credit.
1. Install the packages
Install both packages from git, the SDK first. Keep #v0.1.1 at the end of each URL: it pins the release.
Open Window > Package Manager.
Click +, choose Install package from git URL..., enter this and click Install:
https://github.com/pingcoregaming/pingcore-unity.git?path=/Packages/io.pingcore.sdk#v0.1.1Do the same with the Editor plugin:
https://github.com/pingcoregaming/pingcore-unity.git?path=/Packages/io.pingcore.editor#v0.1.1You should see PingCore SDK and PingCore Editor at 0.1.0 under In Project, and Window > PingCore in the menu.
To add both in one edit instead, put the two lines in Packages/manifest.json:
{
"dependencies": {
"io.pingcore.sdk": "https://github.com/pingcoregaming/pingcore-unity.git?path=/Packages/io.pingcore.sdk#v0.1.1",
"io.pingcore.editor": "https://github.com/pingcoregaming/pingcore-unity.git?path=/Packages/io.pingcore.editor#v0.1.1"
}
}The SDK's connection approval compiles only when Netcode for GameObjects 2.x is in the project. Beacon Rush uses 2.11.2.
2. The game server pieces
On a fleet, your game server talks to PingCore only through the SDK's FleetSdk. The Game Server SDK has the code for each item.
Read the port from
-port <n>on the command line (Assets/Game/Hosting/ServerArgs.cs).Listen on all addresses: bind Unity Transport to
0.0.0.0on that port (Assets/Game/Networking/BeaconRushNetwork.cs).Create the SDK once with
FleetSdk.Create(), and subscribe toAllocationReceivedandAllocationClearedbefore you start it. It does nothing when the game runs outside PingCore, so one build runs everywhere.Start it, then write 0 to the
playerscounter before you listen. From that first write on, the game server stays out of rotation until it calls ready. Writeplayersonly, neversessions.Install
PingCoreConnectionApprovalwithHostedAdmissionEvidenceand your ownIAdmissionGate, then callStartServer(Assets/Game/Hosting/GameServerRuntime.cs,Assets/Game/Admission/BeaconRushAdmissionGate.cs).Call
ReadyAsynconce you listen. A game server that writes a counter and never calls ready never gets a player.Keep
playerscurrent as players join and leave (Assets/Game/Hosting/PlayersCounterWriter.cs).End every session. A match arrives on
AllocationReceived. When it is over, callEndSessionAsyncwith its allocation id (Assets/Game/Hosting/HostedMode.cs). If you turn on the claim that lets Quick play seat a lone player on an idle game server, end that session too, including when the player never arrives.Stop cleanly. From
Application.quitting, callNotifyStoppingon the approval andNotifyProcessStoppingon the SDK.
Give the approval a protocol version of your own and raise it whenever a change breaks compatibility between client and game server builds. A client with another number is refused with protocol_mismatch.
3. The client pieces
The Client SDK has the code for each item.
Keep one client settings asset. Connect in the PingCore window writes your fleet's public app id into it, and creates
Assets/PingCore/Resources/PingCoreClientSettings.assetwhen the project has none. Beacon Rush reads its asset inAssets/Client/ClientBootstrap.cs.Create one
DiscoveryClientper Discovery app (Assets/Client/Flows/ClientServices.cs). It takes only a publicdscp_id.Show what is missing. Run
InfrastructureCheck.RunAsyncat launch and after a failed join, and show the report to the player (Assets/Client/UI/ClientUi.Infrastructure.cs).Get a seat with
QuickJoinAsync,ReserveAsync, orSubmitTicketAsyncandWaitAsync(Assets/Client/UI/ClientUi.Matchmaking.cs,ClientUi.Browse.cs).Join with a join ticket. Build it with
JoinTicket.ForReservationorTicketHandle.CreateJoinTicket, encode it into Netcode for GameObjects' connection data, set the address and port from Discovery's answer, and callStartClient(Assets/Client/Flows/GameConnection.cs).
4. A Linux Dedicated Server build profile
The plugin builds only from a build profile of your own.
Open File > Build Profiles.
Pick Linux Server and click Add Build Profile.
Add your game server's scenes to it.
You should see the profile under Build profile in the PingCore window's Ship section. Until it exists, Ship says "This project has no Linux Dedicated Server build profile. Create one in File > Build Profiles: pick Linux Server (Dedicated Server), then Add Build Profile, and set its scenes."
Screenshot: File > Build Profiles with a Linux Server build profile added and its scene list.
Beacon Rush's profile is Assets/Settings/Build Profiles/Beacon Rush Server.asset, with the one scene Assets/Game/Scenes/Server.unity.
5. Your game in the panel
Set the game up with your own name, player counts and resources. Each piece links to the page that covers it.
A CDN source for your builds: a manual source on Linux, under a category. See CDN Sources and Push Tokens.
The game and its branch, with the branch's Data Source set to that CDN source. See Game Overview and Game Branches.
The startup command, in the template set's Command Line config (below). See Template Sets.
A container on the public PingCore Ubuntu base image, with a
game-portport on TCP + UDP. Unity Transport uses UDP, so a TCP-only port lets the game server start while every player's connection times out. See Containers.A deployment spec whose Port Mapping maps
game-portto your port variable. See Deployment.
The startup command and its port variable
On the Command Line config's Configuration tab, set Process Name to your build's executable with
./in front, for example./MyGame.x86_64.Add a variable
GAMEPORTwith Type Port, Parent Wrapper%USERVAL%, Default Value7777, and Hide in Web on, so players never edit it.Set the template to:
-batchmode -nographics -port %GAMEPORT%
Screenshot: the Command Line config's Variables tab with the GAMEPORT variable.
The process name is the file your build must contain. Build in the PingCore window names the executable after it, and Push refuses a build that does not hold it. Do not add -logFile to the command line: Unity would then write the game server's log to that file instead of standard output.
The port mapping is what puts each game server's own port into GAMEPORT. Any name works, as long as the variable, the template and the mapping use the same one.
6. A fleet
Open Servers > Fleets, click Add Fleet, name it and pick your game, then click Create. See Fleets Overview.
Leave the Agent Settings card as it is. The
playerscounter takes the deployment's player count,sessionsis 1, and Agones-compatible SDK is on. Without that switch,FleetSdkstays inactive.Decide how players get a token. On the fleet's Discovery app, under Player Access, turn on Anonymous player tokens for a game with no login, or Studio-signed player tokens for a game with its own accounts. Both are off on a new app. See Choosing How Players Connect.
7. The PingCore window
The PingCore Window describes each section.
Create an API key under Settings > API Keys with Key Type Brand.
Open Window > PingCore, paste the key into API key (usr_), click Sign in and pick your fleet.
You should see "This project ships to" and your fleet's name.
Under Ship, pick your build profile, then click Build and Push.
In the panel, open the fleet and click Deploy New. It runs your newest push with no Release (which build runs).
Press Play in your client scene.
Push before you deploy; see Troubleshooting.
What to copy from Beacon Rush, and what to leave
Copy the patterns into your own code:
The boot order in
Assets/Game/Hosting/DedicatedServer.csandHostedMode.cs: start, writeplayers, listen, ready.Session ending in
HostedMode.cs, including a claimed session whose player never arrived.The admission gate in
Assets/Game/Admission/BeaconRushAdmissionGate.cs.The infrastructure banner in
Assets/Client/UI/ClientUi.Infrastructure.cs.Quick play's fallback in
Assets/Client/Models/QuickPlayPlan.cs.Readable refusals in
Assets/Client/Models/ConnectionText.cs, one sentence per reason.One token profile per copy of the game in
Assets/Client/Flows/InteractiveProfile.cs(see The Client SDK).
Leave behind:
Beacon Rush's values: its protocol version, its queue
rush-p2, its 8 players and its executable nameBeaconRushServer.x86_64.Beacon Rush's client settings asset. Your project keeps its own. With more than one in the project, Player hosting names the one the plugin uses and asks you to delete the others.
Anything that holds a credential. Your project needs no key or token. See Keeping Secrets Out of Your Build.
Debug tools in a release build, such as
ServerInstrumentationhooks. The same page shows how the build guard keeps them out.
The Quickstart sample
Quickstart, a sample in the SDK package, plays the Beacon Rush client in your own project against the fleet from Run Beacon Rush on PingCore.
It needs both PingCore packages, the built-in render pipeline, Active Input Handling set to Input Manager (Old) or Both, and Netcode for GameObjects 2.11.2 exactly, or it cannot join Beacon Rush game servers. Use a project with no PingCoreClientSettings asset of its own, never SampleGame.
In Window > Package Manager, select PingCore SDK, open the Samples tab and click Import next to Quickstart.
You should see
Assets/Samples/PingCore SDK/0.1.0/Quickstart/withQuickstart.unity, the client copy inBeaconRush/(leave it as it is) andQuickstartClientSettings.asset.In Window > PingCore, sign in and pick your Beacon Rush fleet. Connect writes its app id into
QuickstartClientSettings.asset.Open
Quickstart.unityand press Play.You should see Quick play and Play on this PC at the top of the menu.
Quick play puts you on a game server alone. Find match needs a second player (Multiplayer Play Mode). Play on this PC hosts a LAN game, which a second copy joins with Direct connect at 127.0.0.1:7777.