Building a Battle Pass¶
A battle pass is a common engagement feature for players. You can implement a Battle Pass for your game by utilizing Beamable's Custom Content capabilities. This is a quick guide for how to think about using Beamable for this feature.
Custom Content¶
First, define a custom content type for the Battle Pass by creating a class that inherits from ContentObject.
Each Battle Pass will have tiers, and each tier can have rewards.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | |
Content Setup¶
Once the custom type is defined, follow these steps to add a Battle Pass content object in the Beamable Content Manager:
- Step 1: Open the Content Manager:
- Unity → Window → Beamable → Open Beam Content
- Step 2: Create a new content object of type Battlepass:
- Select "Battlepass" from the content type list.
- Press the "Create" button.
- Provide a name for the Battle Pass content.
- Step 3: Populate the fields in the Unity Inspector:
- Name the Battle Pass
- Set the
EndDateusing the ISO 8601 format (e.g.,2024-12-31T23:59:59Z). - Define the tiers and rewards (Example in screenshot)
- Step 4: Publish the content:
- Once the Battle Pass is configured, press the Publish button in the Content Manager to push the Battle Pass content live.
Fetching and Using the Battle Pass at Runtime¶
After the Battle Pass is defined and published, use Beamable’s features to fetch and use the content at runtime. In this example, we'll retrieve the Battle Pass.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | |
Adding the Battle Pass to Player Inventory¶
You can add the Battle Pass to a player's inventory using Beamable's Inventory system. Here's how you can use the
Inventory.Update method to store the Battle Pass details, such as its name and end date.
To access items.battlepass, an item named battlepass should be created and published through the Content Manager.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | |
Handling End Date and Expiration Validation in a Microservice¶
You can use Beamable’s Microservices to validate the Battle Pass expiration. Since Battlepass is a custom
ContentObject, the type won't be findable by default in Microservices. You can create or move the Battlepass
custom content script into the Beamable's Common folder, which is also referenced in the Microservices. The folder
can be found in Assets/Beamable/Common.
Microservice method:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | |
Download the full sample code from Beamable Battle Pass Sample. Note: This sample uses the latest Beamable SDK V5.0.0.
Season Passes¶
You can also create a season pass that can be used to unlock new content or features. Currently, there is no sample for this feature; however, here is how to do it. It is very similar to the Battle Pass.
-
Create a
Season Passcontent object: This will include the metadata needed for the season (its offerings, rewards, end time, etc.). -
Inventory or Stats services: You can use these services to track per-player ownership of a season pass, whether they bought it or not.
-
Microservices: Here you can enforce the business side of the season pass (checking current date/time if it's within the window, granting the season's rewards, or performing a cleanup or reset at season boundaries).
