Universal - Game Time - Monitor (Pro)
In Unity, frame-based calculations rely heavily on UnityEngine.Time.deltaTime. Unfortunately, this time calculation is vulnerable to manipulation by cheat or hacking tools that allow unwanted acceleration, deceleration or interruption of your game. AntiCheat has introduced a way to step up against such time manipulation.
Monitor
To monitor the game time, AntiCheat has introduced the 'GameTimeMonitor', which can be found in the 'GUPS.AntiCheat.Monitor.Time' namespace. The monitor tracks the game time and notifies observers of time deviations (no deviation, paused, slowed down, speed up) using the 'GameTimeStatus', that may be caused by a cheater.
Monitor Status
The monitor validates every Update callback the possible game time deviation. After every validation observers will be notified with the 'GameTimeStatus'. This status has one property:
- Deviation: Represents the deviation of game time, indicating any time-related manipulations.
The 'Deviation' property can have the following values:
- None: No time deviation.
- Stopped: Indicates that time has stopped.
- SlowedDown: Indicates that time is slowing down.
- SpeedUp: Indicates that time is speeding up.
Supported Platforms
The monitor is available on all platforms.
Requirements
There are no requirements.
How To Use
The usage is quite simple, attach the 'GameTimeMonitor' to a child GameObject of the 'AntiCheat-Monitor' and setup the 'GameTimeCheatingDetector'.
Add Monitor Component
Add the 'GameTimeMonitor' MonoBehavior from the 'GUPS.AntiCheat.Monitor.Time' namespace to your 'AntiCheat-Monitor' GameObject or better to a child GameObject.
Add the 'GameTimeMonitor' as Component.
The game time validation is performed with every Update callback of the MonoBehavior 'GameTimeMonitor'. During validation, the actual game time provided by Unity is compared to a calculated time based on the ticks of the device's operating system that have been surpassed. Due to possible game-dependent CPU or memory allocation peaks, a tolerance value is used to validate deviations. This can be freely assigned by you in the monitor inspector view.
Everytime a validation was done, a 'GameTimeStatus' is sent to observers (usually detectors next to the monitor) describing if the game time was paused, slowed down or speed up.
Detect Game Time Tampering
To react to the sent status and so validate the calculated time deviations, you need a detector. To do this, use the 'GameTimeCheatingDetector', a detector designed to analyse the status send by the 'GameTimeMonitor' and validate it for cheating.