LostEnemyFix

v1.1.1·Updated 2026-04-19

Fixes EnemyAI's that fail to locate NavMesh by killing them.

Screenshots 4 screenshots

About this mod Author’s original text

v80 Update

Zeekerss implemented the following code implementing part of this mod to the base game:

if (agent.isOnNavMesh)

{

if (destination!= prevDestination && agent.SetDestination(destination))

{

prevDestination = destination;

}

}

else

{

Debug.LogError($"Agent '{enemyType.enemyName}' #{thisEnemyIndex}: Agent not on nav mesh when trying to set destination", base.gameObject);

}

The issue is this implementation just spams a brand new error every frame and does not do anything to fix the problem, yet broke my prior implementation by checking for the same issue before calling SetDestination.

Lost Enemy Fix

This mod throws more meaningful errors when an EnemyAi fails to path on Navmesh and kills enemies that throw too many of these errors.

If you play with modded moons, enemies, or interiors. You may have at some point experienced:

[Error: Unity Log] "SetDestination" can only be called on an active agent that has been placed on a NavMesh.

This error can be thrown for several reasons, making it sometimes hard to track the exact source. This could be from a modded enemy being set up wrong, incorrectly placed AI nodes, or blocked navmesh in any modded interior or moon. When this error is thrown this mod will additionally log the EnemyType, position, target destination, enemy behavior state, and if it is outside or inside the facility.

The Fix

In order to fix this lag and console spawn this mod will kill enemies that throw this particular error.

This is configurable:

Aggressive Kills an enemy after it has thrown ONE SetDestination Error.

Reasonable (Default) Kills an enemy after it has thrown several SetDestination Errors.

Off Leaves Vanilla behavior. (Console will be spammed)

With This Mod: (Aggressive Setting)

Without This Mod:

and it keeps going...

Note:

This mod replaces the call to an EnemyAI's Agent with a custom method.

If the vanilla error persists creating lag, the culprit is likely a modded enemy that overrides or completely replaces the navigation method of the vanilla EnemyAI. This mod will fix all vanilla enemies and modded enemies that inherit from the vanilla EnemyAI.

Credits

Programming by JacobG5 (Me)

Nikki - Paid me to make this. & made icons.

Install & use Install: BepInEx plugin

  1. The archive from playbuff is the mod itself — usually a BepInEx plugin (a .dll or a plugin folder once unzipped).
  2. Recommended: use a community mod manager (such as r2modman) — pick this game, import the mod, and the manager sets up BepInEx and its dependencies for you.
  3. Manual route: install the BepInEx loader in the game folder, then drop the unzipped .dll or plugin folder into BepInEx/plugins/.
  4. Launch the game — the BepInEx console logs every plugin it loads; seeing this mod in the log means it is installed.

Mods with listed dependencies need those installed too, or they will not load. Options are usually changed in-game or in the plugin's config file.

Dependencies

Install these first, or the mod will not work:

BepInEx-BepInExPack

File & checksum

Filename
LostEnemyFix-1.1.1.zip
File size
135.6 KiB