# Example Project

Playflow Cloud for Unreal comes with an example project as an alternative download.

{% hint style="info" %}
The Example Project was made on Unreal Engine 5.5.4 and enables the Json Blueprint Utilities plugin to parse Json Values we receive.
{% endhint %}

{% hint style="success" %}
The Example Project can be [downloaded from Github](https://github.com/mrjamesweston/PlayflowCloudforUnrealExample).
{% endhint %}

Through the Project it has everything set up in a way for you to understand the platform in two configurations: 1v1 and 2v2.

1v1: Is a simple configuration on Playflow with the following requirements on the Matchmaking side:

<figure><img src="https://599571038-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FJOLYZsEpI3ofbnXUKMb9%2Fuploads%2FRnEft5o5YhMxL4afDRfv%2Fimage.png?alt=media&#x26;token=4502428e-3207-420c-98de-fb89515e3753" alt=""><figcaption></figcaption></figure>

We use the default Queue Settings and use no additional rules and our Server Overrides are set to default which are taken in from our Server Configuration.

2v2 is the same way, but just 2 players on each team.

<figure><img src="https://599571038-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FJOLYZsEpI3ofbnXUKMb9%2Fuploads%2FxzM1CZ05O4MOHZT2IMJF%2Fimage.png?alt=media&#x26;token=5a7bc7a4-fc7b-415b-b187-bfa5851d7f80" alt=""><figcaption></figcaption></figure>

Again, taking in the defaults with no additional changes.

When you start up the Project you must go to Blueprints>PCUGI and edit the API Key and LobbyConfigName. The API Key comes from your Game's Playflow Dashboard>Overview> View API Keys. This Key is the Client Key.

<figure><img src="https://599571038-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FJOLYZsEpI3ofbnXUKMb9%2Fuploads%2FTqzQ2adJHg9KozArwLk6%2Fimage.png?alt=media&#x26;token=0c67d527-83c0-4be9-9ed9-5c2ef9a67be9" alt=""><figcaption></figcaption></figure>

These variables are reused across the Example Project, we do not need to edit the LobbyId, PlayerId, or MatchmakingMode as these are set at runtime through the WBP\_MainMenu (located in Blueprints>Widgets>MainMenu)

If we go to the WBP\_MainMenu then we can go over what we do.

Whenever we launch our game we comb through our available regions and dynamically set them using helpers from [region-detection-and-more](https://duel-studios.gitbook.io/playflow-cloud-for-unreal/helpers/region-detection-and-more "mention"). From there we set a default region and generate a random name based on our Platform's User Name (on Windows this is your Username!) and append it with a random digit.

Whenever we click Play we Create a Gamemode Selection Widget and then we can do a few options such as select 1v1, 2v2, or Join via Code.

<figure><img src="https://599571038-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FJOLYZsEpI3ofbnXUKMb9%2Fuploads%2FLFIvHc1GGoLe4SQxC8C5%2Fimage.png?alt=media&#x26;token=d35f767e-5e02-4855-9ea7-d98783fb1d1f" alt=""><figcaption></figcaption></figure>

If we select 1v1 we then [creating-a-lobby](https://duel-studios.gitbook.io/playflow-cloud-for-unreal/lobbies/creating-a-lobby "mention") for our party[^1] and we dynamically set our [MatchmakingMode as 1v1](#user-content-fn-2)[^2].

The same for goes for 2v2, but instead we use 2v2.&#x20;

In both modes, if we successfully start a lobby we save our LobbyID to our PCUGI and start our [lobby-heartbeat](https://duel-studios.gitbook.io/playflow-cloud-for-unreal/lobbies/lobby-heartbeat "mention") to ensure we stay active in the Lobby. Afterwards we display a Widget showing our Player Lobby. Once that Widget is loaded, we start to [subscribe-to-lobby-updates](https://duel-studios.gitbook.io/playflow-cloud-for-unreal/lobbies/subscribe-to-lobby-updates "mention"). Ensuring we never miss an update with our Lobby, if someone joins it or whenever we start Matchmaking we are automatically updated via SSE Events.

This WBP\_PlayerLobby demonstrates how we use [update-player-state](https://duel-studios.gitbook.io/playflow-cloud-for-unreal/matchmaking/update-player-state "mention") which automatically adds a key called "isready" which is ticked as 0 (we use Booleans/Branches to detemine if our player is ready or not. 0 = Not Ready, 1 = Ready). We update our PlayerList based off of our SSE and whenever we update our Player State, it is almost instantly reflected in the Lobby!

[^1]: This is our Lobby Config name, taken from our Game's Configuration>Lobbies.

[^2]: This is the Matchmaking Mode taken from our "party" Lobby Config>Matchmaking.
