Account Balances
Last updated
Last updated
Experimental - Customers are encouraged to test and use this feature in their experiences, but it may still require some additional support
The inventory system supports items being assigned a quantity. By reading and writing the quantity number you can implement various in-game balances and currencies, and things like:
Metagame numbers such as XP, Ranks, High Scores
Consumables, such as potions
Achievement progress amounts
The currency system currently supports two types of currencies, online and offline. Online currencies persist in a player's Collection, and in turn persist across deployments and events. Offline currencies doesn't interact with the user's collection and so don't persist, but can be used for transient currencies or point systems.
To create a currency, create a new Data Asset of type J_CurrencyTypePrimaryAsset
. Once that has been created, open it up and fill in the details. If you want this to be an "online" currency then tick the IsCollectionCurrency
check box. You will also need to fill in DataSourceId
and ObjectId
- refer to the Online Mode section to see where to get those details. If you are making an offline currency then leave these two blank, and IsCollectionCurrency
unselected.
Online currencies require an object definition to be created in the back end. If your project supports it, you may be able to create a user collection object yourself using the web UI - simply add a new object into a non-public collection with some kind of asset (usually a thumbnail image), and ensure it has a currency property by entering { "currency" : "" }
in the Properties section.
The DataSourceId
and ObjectId
for your object can be seen in the Datasource view as shown:
Alternatively, contact a member of the platform team and a Support Engineer can create the object for you. Once they have created the object definition, they will be able to inform you of the DataSourceId
and ObjectId
to use.
Using an online currency also requires that user collections are enabled on the server. Ensure that the following game
live config value is enabled: UserCollection.EnabledOnServers
For an offline currency this isn't required - simply fill in the standard details in the data asset and you can start using it.
Your player Morpheus blueprint should already inherit from BPM_M2_BasePlayerCharacter
. In this case it will already have a wallet component attached.
To make sure the balance is updated, you will need to turn on User Collection Polling using the Live Config setting UserCollection.Polling.ClientEnabled
- see here how to overrride this.
To interact with the players wallet you use the J_CurrencySubsystem
. This has functions to get, give and take currency from the player's wallet. Examples of each of those can be seen below. Getting a currency can be done on a client, but giving or taking must be done from the server.
Note: Currently due to limitation of the collection system, getting a currency can only be done on the client if it is an online currency. You may receive a message saying "User collection service is invalid
" when you run the editor in offline mode.