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 see 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

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

Battle Passes (expansion of Seasonal events)

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

Cloud AI minigame

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

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:

  • Optimize the bandwidth your game uses to be as energy-efficient as possible
  • Prevent your game from running slowly due to frequent server calls or server bottlenecks (rate limiting)

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

Idle Clicker game

In real-time idle clicker and social games, such as farming games and city building games, common considerations include:

  • How to simulate real-time activities in a game that isn't running all the time
  • How the simulation can occur on the cloud to ensure all players' games are updated properly, regardless of time zone or any modifications to date/time on a player's device

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

Loot boxes

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

Starter Packs

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