egametang/ET · error · ArgumentException

Empty path

Error message

Empty path

What it means

In DtCrowd.UpdateMoveRequest, when an agent is in DT_CROWDAGENT_TARGET_REQUESTING state the code reads the agent's corridor path to seed a quick sliced pathfind. If that path list is empty, it throws ArgumentException. An empty corridor at request time means the agent was never given a valid initial position/path before requesting a move target.

Source

Thrown at Packages/cn.etetet.recast/Scripts/Core/Share/Detour.Crowd/DtCrowd.cs:580

            foreach (DtCrowdAgent ag in agents)
            {
                if (ag.state == DtCrowdAgentState.DT_CROWDAGENT_STATE_INVALID)
                {
                    continue;
                }

                if (ag.targetState == DtMoveRequestState.DT_CROWDAGENT_TARGET_NONE
                    || ag.targetState == DtMoveRequestState.DT_CROWDAGENT_TARGET_VELOCITY)
                {
                    continue;
                }

                if (ag.targetState == DtMoveRequestState.DT_CROWDAGENT_TARGET_REQUESTING)
                {
                    List<long> path = ag.corridor.GetPath();
                    if (0 == path.Count)
                    {
                        throw new ArgumentException("Empty path");
                    }


                    // Quick search towards the goal.
                    _navQuery.InitSlicedFindPath(path[0], ag.targetRef, ag.npos, ag.targetPos,
                        _filters[ag.option.queryFilterType], 0);
                    _navQuery.UpdateSlicedFindPath(_config.maxTargetFindPathIterations, out var _);

                    DtStatus status;
                    if (ag.targetReplan) // && npath > 10)
                    {
                        // Try to use existing steady path during replan if possible.
                        status = _navQuery.FinalizeSlicedFindPathPartial(path, ref reqPath);
                    }
                    else
                    {
                        // Try to move towards target when goal changes.
                        status = _navQuery.FinalizeSlicedFindPath(ref reqPath);

View on GitHub (pinned to 5cab01f7a8)

Solutions

  1. Ensure each agent has a valid position and corridor (via crowd.AddAgent with a valid DtCrowdAgentParams and a position on the navmesh) before setting a move target.
  2. Validate ag.corridor.GetPath().Count > 0 before relying on the agent for path requests.
  3. Re-add or reset the agent if its corridor becomes empty due to navmesh changes.

Example fix

// before
crowd.RequestMoveTarget(agent, targetRef, targetPos);

// after — ensure corridor is populated
if (agent.corridor.GetPath().Count == 0)
{
    // re-initialize agent position on navmesh first
    crowd.RemoveAgent(agent);
    agent = crowd.AddAgent(validPos, agentParams);
}
crowd.RequestMoveTarget(agent, targetRef, targetPos);
Defensive patterns

Strategy: validation

Validate before calling

if (agent.corridor.GetPath().Count == 0) { Log.Error("agent corridor empty, re-initialize before move target"); return; }

Prevention

When it happens

Trigger: Calling SetMoveTarget on a crowd agent whose corridor was never initialized (no prior position), or whose corridor was reset/cleared; adding an agent to the crowd but not initializing its corridor before requesting a target.

Common situations: Agent added to crowd without a valid starting poly/ref; the navmesh under the agent is invalid so the corridor reset to empty; race between agent setup and the first crowd Update tick.

Related errors


AI-assisted analysis of egametang/ET@5cab01f7a8 (2026-08-13). Data as JSON: /api/errors/68e4e3b5cc9f3558. Report an issue: GitHub.