• Hello
Search Results for

    Show / Hide Table of Contents

    Description

    Players cheat to get an unfair edge. They change scores, speed the game up, edit saves, or share a modded copy of your app.

    GuardingPearSoftware's AntiCheat runs inside your game. It protects important values, watches for those cheats, and lets you react. Honest players keep a fair game. You decide what happens when someone cheats.

    AntiCheat works in four steps:

    1. Protect the values that matter, such as score, health, saves, and time.
    2. Watch the game and the device for unusual changes.
    3. Detect when a change looks like cheating.
    4. React when you are sure enough, for example by warning the player or closing the game.

    Start with How to start, or pick a problem in the Guides.

    Protect your memory

    Score, health, and position sit in memory. A memory editor can search for those numbers and change them.

    Replace the normal type with a protected one. The rest of your code stays the same. If someone tampers with the protected value, AntiCheat can notice.

    Before and after protected values. The cheat is noticed and the score does not follow the edit.

    Your code before:

    public class ScoreManager : MonoBehaviour
    {
        public int Score = 0;
    
        public int ScoreToWin = 100;
    
        public void AddScore(int value)
        {
            this.Score += value;
            this.CheckIfWon();
        }
    }
    

    Your code with AntiCheat:

    public class ScoreManager : MonoBehaviour
    {
        public ProtectedInt32 Score = 0;
    
        public ProtectedInt32 ScoreToWin = 100;
    
        public void AddScore(int value)
        {
            this.Score += value;
            this.CheckIfWon();
        }
    }
    

    See Memory protection.

    Protect your saves

    Unity PlayerPrefs are easy to open and edit. A player can raise a saved score or unlock content by changing a file.

    ProtectedPlayerPrefs uses the same Get and Set calls. You can also store the file in a path you choose.

    Warning

    Values are encrypted only after you set a Value Encryption Key in the AntiCheat project settings. The default settings leave that key empty.

    Your code before:

    public class Settings : MonoBehaviour
    {
        public int LastScore;
    
        public void Awake()
        {
            this.LastScore = PlayerPrefs.GetInt("Score");
        }
    }
    

    Your code with AntiCheat:

    public class Settings : MonoBehaviour
    {
        public int LastScore;
    
        public void Awake()
        {
            this.LastScore = ProtectedPlayerPrefs.GetInt("Score");
        }
    }
    

    You can also assign the key in the Inspector with ProtectedIntPref and the other pref types.

    See Protecting saved data.

    Protect your time

    Many games use Time.deltaTime for movement and cooldowns. A speed hack manipulates that number, so the cheater moves faster or slower than everyone else.

    Default Unity games trust the device date. A player can move the clock forward to claim a daily reward early.

    ProtectedTime gives you a safer frame time and a safer UTC time.

    Before and after protected game time.

    Your code with AntiCheat:

    public void Update()
    {
        Vector3 movingDirection = this.ReadMoveInput();
        movingDirection *= this.Speed * ProtectedTime.deltaTime;
        this.Move(movingDirection);
    }
    

    See Protecting against speedhacks and Protecting against device clock cheating.

    Protect your input

    Auto clickers and macros press a button faster than a person can. That matters in clicker games, weapons, rhythm games, and fast menus.

    AntiCheat watches each button on each device. ProtectedInput lets a button fire only so often. A normal player loses nothing. A very fast auto clicker does not get extra shots.

    An auto clicker on the second player's gamepad is detected.

    See Protecting against auto clickers.

    Protect your mobile game

    A shared, edited copy of a mobile game can jump higher, score more, or skip a purchase.

    A modded Android game before AntiCheat.

    AntiCheat can notice a changed app and a device that looks unsafe, so you can turn those advantages off.

    After AntiCheat, a modified game can be detected.

    On Android you can check:

    • Which store installed the app
    • Whether the app file still matches the build you shipped
    • Whether the app was signed by you
    • Whether extra code libraries were added
    • Whether known cheat apps are installed

    On Android and iOS you can also check that the package name is still yours. On iOS, AntiCheat can look for a jailbroken device.

    See Protecting an Android build, Cheat apps on Android, and Jailbroken iOS devices.

    Protect your desktop game

    On Windows, macOS, and Linux, cheaters use mod loaders, debuggers, and virtual machines. Many of these tools attach before your game code runs, so AntiCheat detects them and lets you react.

    • Mod loaders such as BepInEx or MelonLoader can load extra code into the game.
    • Debuggers can pause the game and change values.
    • Virtual machines make it easier to inspect memory or automate play.
    Note

    A virtual machine is not always a cheat. Developers, testers, and cloud players often use one. Prefer a soft reaction, such as a flag, instead of closing the game at once.

    Desktop checks are set on the Desktop tab under Edit > Project Settings > GuardingPearSoftware > AntiCheat.

    See Protecting a desktop build.

    In This Article
    Back to top GuardingPearSoftware documentation