Protect your game time against manipulation by using ProtectedTime. ProtectedTime calculates basing on computer time, thread speed and cpu clock rate a custom time save against manipulation through extern tools.
Replace UnityEngine.Time with OPS.AntiCheat.ProtectedTime.
Available operations on ProtectedTime:
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 |
// // Summary: // The time in seconds it took to complete the last frame (Read Only). public static float deltaTime { get; } // // Summary: // The real time in seconds since the game started (Read Only). public static float realtimeSinceStartup { get; } // // Summary: // The time at the beginning of this frame (Read Only). This is the time in seconds // since the start of the game. public static float time { get; } // // Summary: // The scale at which the time is passing. This can be used for slow motion effects. public static float timeScale { get; set; } // // Summary: // The time this frame has started (Read Only). This is the time in seconds since // the last level has been loaded. public static float timeSinceLevelLoad { get; } // // Summary: // The timeScale-independent interval in seconds from the last frame to the current // one (Read Only). public static float unscaledDeltaTime { get; } // // Summary: // The timeScale-independent time for this frame (Read Only). This is the time in // seconds since the start of the game. public static float unscaledTime { get; } |
Example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
// using OPS.AntiCheat; public class ProtectedTimeDemo : MonoBehaviour { void Awake() { Debug.Log(Time.deltaTime + " : " + ProtectedTime.deltaTime); Debug.Log(Time.time + " : " + ProtectedTime.time); ProtectedTime.timeScale = 5; Debug.Log(Time.timeScale + " : " + ProtectedTime.timeScale); Debug.Log(Time.realtimeSinceStartup + " : " + ProtectedTime.realtimeSinceStartup); } } |