Step 1: AntiCheat Prefab
Add the OPS\AntiCheat\Prefabs\AntiCheat.prefab to your first game scene.
Step 2: Detector
The SpeedHack Detector checks if someone cheats with the gametime (Time.deltaTime).
To prevent the cheating use the ProtectedTime class instead of Unitys Time class.
You can attach an delegate getting called when a speed hack is detected.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
private void Awake() { SpeedHackDetector.OnSpeedHackDetected += SpeedHackDetector_OnSpeedHackDetected; } private void SpeedHackDetector_OnSpeedHackDetected(bool _CalledThroughThread, ESpeedingType _SpeedingType) { //There is a bool _CalledThroughThread, to notify you, if the delegate gets called through a thread. //_SpeedingType is an enum contains three values. Stopped, SlowedDown, SpeedUp. Those tell you what the cheater does. //Cannot access UnityEngine Ui trough thread! if (_CalledThroughThread) { return; } switch (_SpeedingType) { case ESpeedingType.Stopped: { Text.text = "Speed Hack Detected! Cheater stopped the Game!"; break; } case ESpeedingType.SlowedDown: { Text.text = "Speed Hack Detected! Cheater slowed down the Game!"; break; } case ESpeedingType.SpeedUp: { Text.text = "Speed Hack Detected! Cheater speeded up the Game!"; break; } } } |