Cheat prevention

You can use Cloud Code to isolate critical game logic on servers to ensure that players can't hack or cheat. Instead of potentially vulnerable clients, you use servers as the authoritative source of truth for game state. Cloud Code integrates seamlessly with other UGS services like Remote Config, Cloud Save, and more to build complete backends.

For example, you can use the player client to call Cloud Code functions when important game events occur, such as at the start and end of a game level:

  • At the start of a level, the player client passes parameters that indicate values such as the level number and how many buffs or power-ups the player uses. The Cloud Code function can then save the level start info to a Cloud Save object associated with the player. It can also decrement the number of available buffs for that player.

  • At the end of the level, the player client passes parameters that indicate values such as the completed level number, the player's score, or number of items they used. The server can then validate that the level completed matches the level started earlier. It can check that the score is within valid ranges for that level and decrement the player's inventory of items.

  • If the player's score passes a threshold to unlock the next set of levels, the Cloud Code function can update the player's progress and return data to indicate that the new levels that are now accessible.

For a more detailed example of how you can model your game state on a cloud server to prevent cheating, refer to Game state management.