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

Inherits ACTkDetectorBase< WallHackDetector >.

Public Member Functions

void TriggerDetection ()
 

Static Public Member Functions

static WallHackDetector AddToSceneOrGetExisting ()
 
static WallHackDetector StartDetection ()
 
static WallHackDetector StartDetection (Action callback)
 
static WallHackDetector StartDetection (Action callback, Vector3 spawnPosition)
 
static WallHackDetector StartDetection (Action callback, Vector3 spawnPosition, byte maxFalsePositives)
 
static void StopDetection ()
 
static void Dispose ()
 

Public Attributes

int wireframeDelay = 10
 
int raycastDelay = 10
 
Vector3 spawnPosition
 
byte maxFalsePositives = 3
 
bool autoStart
 
bool autoDispose
 

Properties

bool CheckRigidbody [get, set]
 
bool CheckController [get, set]
 
bool CheckWireframe [get, set]
 
bool CheckRaycast [get, set]
 
bool IsCheatDetected [get, protected set]
 
bool IsStarted [get, protected set]
 
bool IsRunning [get, protected set]
 

Events

Action CheatDetected
 

Detailed Description

Detects common types of wall hack cheating: walking through the walls (Rigidbody and CharacterController modules), shooting through the walls (Raycast module), looking through the walls (Wireframe module).

In order to work properly, this detector creates and uses some service objects right in the scene.
It places all such objects within 3x3x3 sandbox area which is placed at the spawnPosition and drawn as a red wire cube in the scene when you select Game Object with this detector.
Please, place this sandbox area at the empty unreachable space of your game to avoid any collisions and false positives.

To get started:

  • add detector to any GameObject as usual or through the "GameObject > Create Other > Code Stage > Anti-Cheat Toolkit" menu;
  • make sure 3x3x3 area at the spawnPosition is unreachable for any objects of your game;

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.

Note #1: Adds new objects to the scene and places them into the "[WH Detector Service]" container at the spawnPosition.
Note #2: May use physics and shaders. It may lead to the build size increase and additional resources usage.

Member Function Documentation

◆ AddToSceneOrGetExisting()

static WallHackDetector 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/4]

static WallHackDetector StartDetection ( )
inlinestatic

Starts 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/4]

static WallHackDetector StartDetection ( Action  callback)
inlinestatic

Starts 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/4]

static WallHackDetector StartDetection ( Action  callback,
Vector3  spawnPosition 
)
inlinestatic

Starts detection with specified callback using passed spawnPosition.

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.
spawnPositionWorld position of the service 3x3x3 container. Overrides spawnPosition property.

◆ StartDetection() [4/4]

static WallHackDetector StartDetection ( Action  callback,
Vector3  spawnPosition,
byte  maxFalsePositives 
)
inlinestatic

Starts detection with specified callback using passed spawnPosition 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.
spawnPositionWorld position of the service 3x3x3 container. Overrides spawnPosition property.
maxFalsePositivesAmount of possible false positives in a row before registering detection. Overrides maxFalsePositives 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 and destroys Service Container as well.

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

◆ wireframeDelay

int wireframeDelay = 10

Delay between Wireframe module checks, from 1 up to 60 secs.

◆ raycastDelay

int raycastDelay = 10

Delay between Raycast module checks, from 1 up to 60 secs.

◆ spawnPosition

Vector3 spawnPosition

World coordinates of the service container. Please keep in mind it will have different active objects within 3x3x3 cube during gameplay. It should be unreachable for your game objects to avoid collisions and false positives.

◆ maxFalsePositives

byte maxFalsePositives = 3

Maximum false positives in a row for each detection module before registering a wall hack.

◆ 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

◆ CheckRigidbody

bool CheckRigidbody
getset

Check for the "walk through the walls" kind of cheats made via Rigidbody hacks?

Disable to save some resources if you're not using Rigidbody for characters.

◆ CheckController

bool CheckController
getset

Check for the "walk through the walls" kind of cheats made via Character Controller hacks?

Disable to save some resources if you're not using Character Controllers.

◆ CheckWireframe

bool CheckWireframe
getset

Check for the "see through the walls" kind of cheats made via shader or driver hacks (wireframe, color alpha, etc.)?

Disable to save some resources in case you don't care about such cheats.

NOTE: Uses specific shader under the hood. Thus such shader should be included into the build to exist at runtime.
You may easily add or remove shader at the ACTk Settings window (Window > Code Stage > Anti-Cheat Toolkit > Settings).
You'll see error in logs at runtime if you'll have no needed shader included.

◆ CheckRaycast

bool CheckRaycast
getset

Check for the "shoot through the walls" kind of cheats made via Raycast hacks?

Disable to save some resources in case you don't care about such cheats.

◆ 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.