Advanced use cases
You can write much of your game logic with Cloud Code. However, it might not be obvious how to connect different services together from within scripts or how that would fit in as a game mechanic.
Explore the Use cases to better understand how Cloud Code scripts are written and the problems they can solve. Examples include:
- Server time anti-cheat mechanisms
- In-game coupons
- Daily rewards
Below you can find more advanced use cases. Download the Unity Gaming Services Samples project to check how to implement Cloud Code to solve common game development challenges:
Project | Summary | Integrated UGS services |
---|---|---|
A/B testing | An A/B test is a useful mechanism for tweaking a single feature of game play or game design and determining the variation of that feature that most engages players. | Authentication, Cloud Save, Economy, Remote Config, Cloud Code, and Analytics |
Seasonal events can increase game sessions and overall interest in a game by giving existing players new and fun content throughout the year to look forward to, and enticing new players to begin playing. This sample shows how you can set up seasonal events (fall, winter, spring, summer) for players in your game with a countdown indicating how much time is left in the current event, the currency rewards players can win during the event, and a Play Challenge button that, when selected, opens a pop-up window where players can collect their rewards for winning the challenge. | Authentication, Economy, Cloud Code, Remote Config, Addressables, Analytics and Cloud Save | |
A seasonal points-based reward system is a popular and effective way to retain players in a game over time. Unlike a time-based reward system, it requires an element of skill to progress through the reward track. The Battle Pass adds another layer of exclusive appeal to this system, while also adding a monetization mechanic by letting players purchase a second premium track with additional rewards. This sample uses currencies as premium rewards, though most games are designed to award cosmetic items at the premium level or other items that do not give players a gameplay advantage. | Authentication, Economy, Cloud Code, Remote Config, Addressables, and Cloud Save | |
In some games, it's desirable to play a minigame as a reward or to advance gameplay. This sample demonstrates how to use Cloud Code with other UGS packages to validate gameplay in a minigame that implements a simple artificial opponent against the player. Additionally, this sample demonstrates how to reward gameplay based on the game outcome by awarding bonus coins for wins and ties. Rewarding gameplay in this way can make the minigames more enjoyable and even affect the game economy going forward. | Authentication, Cloud Code, Economy, and Cloud Save | |
Command batching is the concept where each game action is a command that you can collect into a queue to send to the server in batches for processing. Using command batching can:
Optimizing your game with command batching provides users with a more pleasant game experience with less wait times by reducing the number and/or frequency of server calls your game makes. | Cloud Code, Remote Config, Economy, and Cloud Save | |
In real-time idle clicker and social games, such as farming games and city building games, common considerations include:
This sample scenario shows how to solve both challenges while limiting calls to UGS, which can cause throttling issues or increased costs. | Authentication, Cloud Code, Economy, and Cloud Save | |
Games of various genres, from team-based multiplayer games to first-person shooters, make use of loot boxes and grant random currency, items, and equipment to the player to reward them for leveling up or completing long stretches of gameplay without quitting. Loot boxes are a great way for players to feel engaged and motivated to keep playing and get rewarded for it. This sample shows how to set up a basic loot box in your game, or in other words, how to grant random currency to players. | Economy and Cloud Code | |
It's common in games to offer a one-time virtual purchase, such as a Starter Pack, to give players a boost when first playing your game or when players delete their game save and start again. This sample shows how to create a one-time deal Starter Pack in your game that a player can purchase with in-game currency. | Authentication, Economy, Cloud Code, and Cloud Save |