Anti-Cheat Toolkit  2023.2.6
Multi-purpose anti-cheat solution for Unity Engine
SpeedHackDetector Class Reference

Inherits ACTkDetectorBase< SpeedHackDetector >.

Public Member Functions

void TriggerDetection ()
 

Static Public Member Functions

static SpeedHackDetector AddToSceneOrGetExisting ()
 
static SpeedHackDetector StartDetection ()
 
static SpeedHackDetector StartDetection (Action callback)
 
static SpeedHackDetector StartDetection (Action callback, float interval)
 
static SpeedHackDetector StartDetection (Action callback, float interval, byte maxFalsePositives)
 
static SpeedHackDetector StartDetection (Action callback, float interval, byte maxFalsePositives, int coolDown)
 
static void StopDetection ()
 
static void Dispose ()
 

Public Attributes

float interval = 1f
 
float threshold = 0.2f
 
byte maxFalsePositives = 3
 
int coolDown = 30
 
bool autoStart
 
bool autoDispose
 

Properties

bool UseDsp [get, set]
 
bool IsCheatDetected [get, protected set]
 
bool IsStarted [get, protected set]
 
bool IsRunning [get, protected set]
 

Events

Action CheatDetected
 

Detailed Description

Allows to detect Cheat Engine's speed hack (and maybe some other speed hack tools) usage.

Just add it to any GameObject as usual or through the "GameObject > Create Other > Code Stage > Anti-Cheat Toolkit" menu to get started.
You can use detector completely from inspector without writing any code except the actual reaction on cheating.

Avoid using detectors from code at the Awake phase.

Member Function Documentation

◆ AddToSceneOrGetExisting()

static SpeedHackDetector AddToSceneOrGetExisting ( )
inlinestatic

Creates new instance of the detector at scene if it doesn't exists. Make sure to call NOT from Awake phase.

Returns
New or existing instance of the detector.

◆ StartDetection() [1/5]

static SpeedHackDetector StartDetection ( )
inlinestatic

Starts speed hack detection for detector you have in scene.

Make sure you have properly configured detector in scene with autoStart disabled before using this method.

◆ StartDetection() [2/5]

static SpeedHackDetector StartDetection ( Action  callback)
inlinestatic

Starts speed hack detection with specified callback.

If you have detector in scene make sure it has empty Detection Event.
Creates a new detector instance if it doesn't exists in scene.

Parameters
callbackMethod to call after detection.

◆ StartDetection() [3/5]

static SpeedHackDetector StartDetection ( Action  callback,
float  interval 
)
inlinestatic

Starts speed hack detection with specified callback using passed interval.

If you have detector in scene make sure it has empty Detection Event.
Creates a new detector instance if it doesn't exists in scene.

Parameters
callbackMethod to call after detection.
intervalTime in seconds between speed hack checks. Overrides interval property.

◆ StartDetection() [4/5]

static SpeedHackDetector StartDetection ( Action  callback,
float  interval,
byte  maxFalsePositives 
)
inlinestatic

Starts speed hack detection with specified callback using passed interval and maxFalsePositives.

If you have detector in scene make sure it has empty Detection Event.
Creates a new detector instance if it doesn't exists in scene.

Parameters
callbackMethod to call after detection.
intervalTime in seconds between speed hack checks. Overrides interval property.
maxFalsePositivesAmount of possible false positives. Overrides maxFalsePositives property.

◆ StartDetection() [5/5]

static SpeedHackDetector StartDetection ( Action  callback,
float  interval,
byte  maxFalsePositives,
int  coolDown 
)
inlinestatic

Starts speed hack detection with specified callback using passed interval, maxFalsePositives and coolDown.

If you have detector in scene make sure it has empty Detection Event.
Creates a new detector instance if it doesn't exists in scene.

Parameters
callbackMethod to call after detection.
intervalTime in seconds between speed hack checks. Overrides interval property.
maxFalsePositivesAmount of possible false positives. Overrides maxFalsePositives property.
coolDownAmount of sequential successful checks before resetting false positives counter. Overrides coolDown property.

◆ StopDetection()

static void StopDetection ( )
inlinestatic

Stops detector. Detector's component remains in the scene. Use Dispose() to completely remove detector.

◆ Dispose()

static void Dispose ( )
inlinestatic

Stops and completely disposes detector component.

On dispose Detector follows 2 rules:

  • if Game Object's name is "Anti-Cheat Toolkit Detectors": it will be automatically destroyed if no other Detectors left attached regardless of any other components or children;
  • if Game Object's name is NOT "Anti-Cheat Toolkit Detectors": it will be automatically destroyed only if it has neither other components nor children attached;

◆ TriggerDetection()

void TriggerDetection ( )
inline

Manually triggers cheating detection and invokes assigned events.

Member Data Documentation

◆ interval

float interval = 1f

Time (in seconds) between detector checks.

◆ threshold

float threshold = 0.2f

Allowed speed multiplier threshold. Do not set to too low values (e.g. 0 or 0.00*) since there are timer fluctuations on different hardware.

◆ maxFalsePositives

byte maxFalsePositives = 3

Maximum false positives count allowed before registering speed hack.

◆ coolDown

int coolDown = 30

Amount of sequential successful checks before clearing internal false positives counter.
Set 0 to disable Cool Down feature.

◆ autoStart

bool autoStart
inherited

Allows to start detector automatically. Otherwise, you'll need to call StartDetection() method to start it.

Useful in conjunction with proper Detection Event configuration in the inspector. Allows to use detector without writing any code except the actual reaction on cheating.

◆ autoDispose

bool autoDispose
inherited

Detector component will be automatically disposed after firing callback if enabled. Otherwise, it will just stop internal processes.

On dispose Detector follows 2 rules:

  • if Game Object's name is "Anti-Cheat Toolkit": it will be automatically destroyed if no other Detectors left attached regardless of any other components or children;
  • if Game Object's name is NOT "Anti-Cheat Toolkit": it will be automatically destroyed only if it has neither other components nor children attached;

Property Documentation

◆ UseDsp

bool UseDsp
getset

Controls whether to use DSP Timer to catch speed hacks in sandboxed environments (like WebGL, VMs, etc.).

Uses AudioSettings.dspTime under the hood, which can catch some extra speed hacks in sandboxed environments but can potentially cause false positives on some hardware due to way too high sensitivity. WARNING: Use at your peril!

◆ IsCheatDetected

bool IsCheatDetected
getprotected setinherited

Indicates if cheat was detected by this detector.

◆ IsStarted

bool IsStarted
getprotected setinherited

Allows to check if detector is started (stays true even when it's paused).

◆ IsRunning

bool IsRunning
getprotected setinherited

Allows to check if detection is currently running and not paused.

Event Documentation

◆ CheatDetected

Action CheatDetected
inherited

Subscribe to this event to get notified when cheat will be detected.