Desktop - Instance Lock - Detector (Pro)
A player can start your game twice on the same computer. In a multiplayer game that can be used to cheat. One copy plays, and the other copy feeds it information or farms rewards.
This detector notices a second copy of your game on the same computer, so you can react. It does not close the game.
This detector needs the Pro version.
Walkthrough: Protecting a desktop build.
Important
This check is off by default. Local co-op may start a second copy on purpose, and that is harmless. Turn it on only when a second copy is a problem in your game.
Do you need to add it?
Most of the time, no. The predefined Anti-Cheat-Monitor prefab already includes the Desktop Instance Lock Detector prefab. You only have to turn the check on in the project settings.
If you use your own monitor prefab, drag the Desktop Instance Lock Detector prefab onto the monitor in your prefab so it becomes a child.

The detector prefabs in Assets/GUPS/AntiCheat/Resources/Prefabs/Detectors.
The component is DesktopInstanceLockDetector (namespace GUPS.AntiCheat.Detector.Desktop). It does not need a monitor.
Settings
In the project settings
Open Edit > Project Settings > GuardingPearSoftware > AntiCheat. Select the Desktop tab and go to Desktop - Instance Lock - Settings.
- Lock to a single instance (
Desktop_LockSingleInstance, default off): On means a second copy of this game on the same computer is reported. While it is off, nothing is checked and nothing is reported.
On the detector
- Is Active (
isActive, bool, default on): Turns the detector on or off. - Possibility Of False Positive (
possibilityOfFalsePositive, float, range 0 to 1, default 0.05): How likely a find is a false alarm. It is low, because you turned the check on yourself. - Threat Rating (
threatRating, uint, default 400): How much a find adds to the threat score of the Anti-Cheat Monitor. - On Cheating Detection Event (
OnCheatingDetectionEvent): Your own reactions. Assign a method here.
What it reports
When a second copy is found, the detector sends a DesktopCheatingDetectionStatus:
public struct DesktopCheatingDetectionStatus : IDesktopCheatingDetectionStatus
{
// How likely this find is a false alarm, from 0 to 1.
public float PossibilityOfFalsePositive { get; }
// How much this find adds to the threat score.
public uint ThreatRating { get; }
// What was found. For this detector it is always MULTIPLE_INSTANCES.
public EDesktopCheatingType DesktopCheatingType { get; }
// A short text that says what was found. It holds no file path.
public string Evidence { get; }
}
DesktopCheatingType is:
MULTIPLE_INSTANCES = 40 // Another copy of this game is already running on this computer.
Good to know
- Which copy reports. The first copy runs as normal. The second copy is the one that reports. So react in the copy that was started last.
- What counts as the same game. Two copies with the same company name and product name, even from two different folders. Other games do not count.
- It checks once, when the game starts. You can also check yourself with
ManualScan(). It returns true when another copy is running. - A crash does not block the next start. When the first copy quits, crashes, or is closed by force, the next start is not reported.
- The game is not closed. With the default settings, one find is enough for the soft built-in punishers, but not for the Exit Game punisher. The predefined monitor prefab has no punisher, so a find only raises the threat score until you react yourself or add a punisher.
PossibleCheatingDetected stays true after the find.
Platforms and requirements
- Windows, macOS, and Linux standalone builds.
- No extra plugin is needed.
Note
The detector skips the Unity Editor and development builds. Turn on Verify development builds on the Desktop tab to run it there too. A game running in the Editor then counts as the first copy, so a built player started next to it is reported.
React to a find
In the Inspector. Add a method to On Cheating Detection Event. It runs when a second copy is found.
In code. Ask the detector:
var detector = AntiCheatMonitor.Instance.GetDetector<DesktopInstanceLockDetector>();
if (detector != null && detector.PossibleCheatingDetected)
{
// Another copy of the game is already running.
}
A common reaction is to show a message and close this copy:
using GUPS.AntiCheat;
using GUPS.AntiCheat.Detector.Desktop;
using UnityEngine;
public class SecondCopyGuard : MonoBehaviour
{
private void Start()
{
var detector = AntiCheatMonitor.Instance.GetDetector<DesktopInstanceLockDetector>();
if (detector != null && detector.ManualScan())
{
Debug.LogWarning("The game is already running.");
Application.Quit();
}
}
}
Or listen, so your code runs at the moment of the find:
using System;
using GUPS.AntiCheat;
using GUPS.AntiCheat.Core.Detector;
using GUPS.AntiCheat.Detector.Desktop;
using UnityEngine;
public class SecondCopyLogger : MonoBehaviour, IObserver<IDetectorStatus>
{
private void Start()
{
var detector = AntiCheatMonitor.Instance.GetDetector<DesktopInstanceLockDetector>();
detector.Subscribe(this);
}
public void OnNext(IDetectorStatus status)
{
if (status is DesktopCheatingDetectionStatus desktopStatus)
{
Debug.LogWarning($"Second copy found: {desktopStatus.Evidence}");
}
}
public void OnError(Exception error) { }
public void OnCompleted() { }
}
Back to the Detector overview.