This project consists in an Unity Tic-Tac-Toe game with multiplayer support.
Before configuring this project, first ensure you have completed the next pre-requisites:
-
Clone this project in your computer (
git clone https://github.com/southworks/playfab.git
). -
Download and install Unity Hub and Unity IDE (link).
-
Download the PlayFab Unity Editor Extension Asset Package
NOTE: save the .unitypackage file in an accessible folder, as we'll be using it later
-
Read and complete the Azure Function configuration.
The next steps will guide you for doing the PlayFab configuration:
-
Create a PlayFab account (tutorial), or sing-in into your current account.
-
Create a new PlayFab Title in your PlayFab account.
-
Create a Matchmaking queue in your PlayFab Title for the QuickMatch feature:
- Open your Title and go to
Build/Multiplayer/Matchmaking
. - Press the
New Queue
button. - In the Creation page, enter the following:
- Queue Name:
TicTacToeQuickMatch
. - Match Size:
Min = 2
;Max = 2
. - Rules:
- Rule Name:
UserSkillRule
. - Weight:
1
. - Type: select the
String Equality Rule
option. - Attribute Source: select the
User
option. - Attribute path:
Skill
. - Behavior when the attribute is not specified: select the
Match with any
option.
- Rule Name:
- Queue Name:
- At the end, you'll have something like this:
- Open your Title and go to
-
Create a Matchmaking queue in your PlayFab Title for the QuickMatch feature:
- Open your Title and go to
Build/Multiplayer/Matchmaking
. - Press the
New Queue
button. - In the Creation page, enter the following:
- Queue Name:
PartyQueue
. - Match Size:
Min = 2
;Max = 2
. - Rules:
- Rule Name:
PreviousMatchIdRule
. - Weight:
1
. - Type: select the
String Equality Rule
option. - Attribute Source: select the
User
option. - Attribute path:
PreviousMatchId
. - Behavior when the attribute is not specified: select the
Use default
option.- Default value: type
Default
.
- Default value: type
- Rule Name:
- Queue Name:
- At the end, you'll have something like this:
- Open your Title and go to
-
Configure the project's Azure Functions:
-
Open your Title and go to
Build/Automation/CloudScript/Functions
. -
Do the following steps for each Azure Functions you use in this project:
- Press the
Register Function
button. - Select the
HTTP
Trigger Type option. - Enter your
Function name
. - Enter your
Function URL
NOTE: you can follow this tutorial to get the Function's URL
- Press the
Register Function
button for saving the new function.
- Press the
-
-
Install the PlayFab Unity Package:
- Open the Tic-Tac-Toe Unity Project.
- Navigate to the folder where you have saved the PlayFab Unity Package (it's the .unitypackage file).
- Double-click the PlayFab Unity Package.
- The next prompt will be shown:
- Press the Import button to import these assets into the project.
-
Configure the Unity project:
- First, go to your PlayFab's Title and retrieve your PlayFab's title ID.
- Paste the Title ID in this line of the Constants.cs file.
-
Now, you're able to run the project.