• Hello
Search Results for

    Show / Hide Table of Contents

    Universal - Game Time - Monitor (Pro)

    Many games use Time.deltaTime for movement and cooldowns. A speed hack is a tool that makes that clock run too fast, too slow, or stop. This monitor measures how fast the game clock really runs.

    It only reports the speed. The Game Time Cheating Detector decides if that is cheating.

    This monitor needs the Pro version.

    Walkthrough: Protecting against speedhacks.

    Do you need to add it?

    Most of the time, no. The Game Time Cheating Detector prefab already includes this monitor. That prefab is part of the predefined Anti-Cheat-Monitor prefab.

    Add the GameTimeMonitor component (namespace GUPS.AntiCheat.Monitor.Time) by hand only if you build your own setup, or if you only want the raw readings. Put it on the same GameObject as its detector. The detector looks for it there.

    Add the GameTimeMonitor component.

    What it reports

    The monitor sends a GameTimeStatus, about ten times per second:

    public struct GameTimeStatus : IWatchedSubject
    {
        // How the game clock compares with real time.
        public EGameTimeDeviation Deviation { get; }
    
        // How fast the game clock runs. 1.0 = real speed, 2.0 = twice as fast.
        public float SpeedFactor { get; }
    }
    
    • Deviation: Whether the speed is outside the tolerance you set.
    • SpeedFactor: How fast the game clock runs. 1 is normal. 2 is twice as fast.

    Deviation uses this enum:

    public enum EGameTimeDeviation : byte
    {
        None = 0,       // The clock runs at normal speed.
        Stopped = 1,    // The clock stands still.
        SlowedDown = 2, // The clock runs too slow.
        SpedUp = 3      // The clock runs too fast.
    }
    

    Settings

    The monitor has two fields in the Inspector:

    • Is Active (isActive, bool, default true): Turns the monitor on or off.
    • Tolerance Factor (toleranceFactor, float, range 0.05 to 1, default 0.25): How far the game speed may drift from real time before it is reported. 0.25 reports 1.25 times and faster, or 0.75 times and slower. A good range is 0.15 to 0.3. Do not go below 0.1, or normal small timing errors are reported.

    Good to know

    • Why a second clock: A speed hack changes all the normal clocks a game can read by the same amount. Comparing two of them shows nothing. The monitor compares the game clock with a real-time clock that these tools cannot easily fake.
    • Pause and slow motion are fine: Changing Time.timeScale is not reported. A frame hitch or a scene load is not reported either.
    • What it finds: Speed hacks such as the Speedhack in Cheat Engine, and a game clock that was edited in memory.
    • What it does not find: A tool that slows down the whole computer, not only the game. The real-time clock slows down with it.
    • The physics step: The monitor does not report Time.fixedDeltaTime. The detector checks that itself.

    Platforms and requirements

    The monitor works on every platform and has no extra requirements.

    On WebGL the protection is weaker. A speed hack that also changes the browser clock can fool the monitor there.

    Read it in code

    You can listen to the monitor yourself. Subscribe returns an IDisposable. Dispose it when you want to stop.

    using System;
    using GUPS.AntiCheat.Core.Watch;
    using GUPS.AntiCheat.Monitor.Time;
    using UnityEngine;
    
    public class GameTimeStatusLogger : MonoBehaviour, IObserver<IWatchedSubject>
    {
        private void Start()
        {
            var monitor = GetComponentInChildren<GameTimeMonitor>();
            monitor.Subscribe(this);
        }
    
        public void OnNext(IWatchedSubject subject)
        {
            if (subject is GameTimeStatus status)
            {
                Debug.Log($"Deviation: {status.Deviation}, Speed: {status.SpeedFactor:0.00}x");
            }
        }
    
        public void OnError(Exception error) { }
        public void OnCompleted() { }
    }
    

    Detect a speed hack

    To decide if a reading is cheating, use the Game Time Cheating Detector.


    Back to the Monitor overview.

    In This Article
    Back to top GuardingPearSoftware documentation