Protected
Cheaters look for values they can change: score, health, saves, time, and button presses. They often use tools like Cheat Engine or GameGuardian. Protected types keep those values safer and can notice when someone tampers with them.
You replace a normal Unity type or call with the Anti-Cheat protected version. In most cases the rest of your code stays the same.
The Free version includes protected primitives and PlayerPrefs. Everything else on this page needs Pro.
Pick the section that fits what you want to protect:
- Score, health, or currency: Memory
- Saved settings and progress: PlayerPrefs
- Timers, cooldowns, and daily rewards: Time
- Buttons and clicks: Input
What happens when a value is changed
Protected types report a change to a detector. The detector decides if it looks like cheating. Then you can decide what to do about it.
So add the matching detector to the Anti-Cheat Monitor. Each page below names the one you need.
Memory
A memory editor is a tool that reads and changes the values of a running game. It can search for a plain number and overwrite it. Protected types hide the real value and check it when you use it.
Before:
int score = 100;
score += 10;
After:
ProtectedInt32 score = 100;
score += 10;
| Type | Free | Pro | What it is for |
|---|---|---|---|
| Primitives | + | + | Single values such as int, float, bool, string, decimal, DateTime, Vector3, and Quaternion |
| Collections | + | A whole list, queue, or stack. You ask it to check itself when you want | |
| Data chain | + | A log you add to or remove from only at the end, such as scores or currency. It checks itself on every change | |
| Block chain | + | A data chain that can also be saved to a file or your server, and loaded back |
Collections and chains hold value types (structs) by default, such as numbers and vectors.
Guide: Memory protection.
PlayerPrefs
Unity PlayerPrefs are stored in the open. A player can edit them. Protected PlayerPrefs add a check that notices a changed save. They also encrypt the value, which means they scramble it so it cannot be read, once you set a key.
Before:
PlayerPrefs.SetInt("Coins", 500);
int coins = PlayerPrefs.GetInt("Coins");
After:
ProtectedPlayerPrefs.SetInt("Coins", 500);
int coins = ProtectedPlayerPrefs.GetInt("Coins");
| Type | Free | Pro | What it is for |
|---|---|---|---|
| ProtectedPlayerPrefs | + | + | Same place as Unity PlayerPrefs |
| ProtectedFileBasedPlayerPrefs | + | + | A file you choose. The default folder is Application.persistentDataPath |
Warning
Set a Value Encryption Key in the project settings before you rely on encryption. The shipped settings leave that key empty.
Guide: Protecting saved data.
Time
A speed hack is a tool that makes the game clock run faster or slower. Players can also move the device clock to skip a timer. ProtectedTime gives you a game clock that stays on real speed, and a date and time that does not simply trust the device clock.
Before:
// Game time
transform.position += velocity * Time.deltaTime;
// Device time
DateTime now = DateTime.UtcNow;
After:
// Game time
transform.position += velocity * ProtectedTime.deltaTime;
// Device time
DateTime now = ProtectedTime.UtcNow;
| Type | Free | Pro | What it is for |
|---|---|---|---|
| Game time | + | A safer replacement for Time.deltaTime and the other Time values |
|
| Device time | + | A safer date and time in UTC, the world time without time zones, for rewards, trials, and daily events |
Guides: Speedhacks and Device clock.
Input
An auto clicker can press a button much faster than a person. ProtectedInput limits how often each button counts as pressed, so clicking faster gains nothing.
Before:
if (Keyboard.current[Key.Space].wasPressedThisFrame)
{
Jump();
}
After:
if (ProtectedInput.GetKeyDown(Key.Space))
{
Jump();
}
| Type | Free | Pro | What it is for |
|---|---|---|---|
| Protected input | + | A limit on presses per second for keys, mouse, gamepad, touch, and input actions |
Each button on each device has its own limit. The default is 10 presses per second. You need the Input System package.
Guide: Auto clickers.
Back to the overview.