{"record":{"id":"68e4e3b5cc9f3558","repo":"egametang/ET","slug":"empty-path","errorCode":null,"errorMessage":"Empty path","messagePattern":"Empty path","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"Packages/cn.etetet.recast/Scripts/Core/Share/Detour.Crowd/DtCrowd.cs","lineNumber":580,"sourceCode":"            foreach (DtCrowdAgent ag in agents)\n            {\n                if (ag.state == DtCrowdAgentState.DT_CROWDAGENT_STATE_INVALID)\n                {\n                    continue;\n                }\n\n                if (ag.targetState == DtMoveRequestState.DT_CROWDAGENT_TARGET_NONE\n                    || ag.targetState == DtMoveRequestState.DT_CROWDAGENT_TARGET_VELOCITY)\n                {\n                    continue;\n                }\n\n                if (ag.targetState == DtMoveRequestState.DT_CROWDAGENT_TARGET_REQUESTING)\n                {\n                    List<long> path = ag.corridor.GetPath();\n                    if (0 == path.Count)\n                    {\n                        throw new ArgumentException(\"Empty path\");\n                    }\n\n\n                    // Quick search towards the goal.\n                    _navQuery.InitSlicedFindPath(path[0], ag.targetRef, ag.npos, ag.targetPos,\n                        _filters[ag.option.queryFilterType], 0);\n                    _navQuery.UpdateSlicedFindPath(_config.maxTargetFindPathIterations, out var _);\n\n                    DtStatus status;\n                    if (ag.targetReplan) // && npath > 10)\n                    {\n                        // Try to use existing steady path during replan if possible.\n                        status = _navQuery.FinalizeSlicedFindPathPartial(path, ref reqPath);\n                    }\n                    else\n                    {\n                        // Try to move towards target when goal changes.\n                        status = _navQuery.FinalizeSlicedFindPath(ref reqPath);","sourceCodeStart":562,"sourceCodeEnd":598,"githubUrl":"https://github.com/egametang/ET/blob/5cab01f7a8bee5f49f4781eebe9e2b1c6d7ebe0f/Packages/cn.etetet.recast/Scripts/Core/Share/Detour.Crowd/DtCrowd.cs#L562-L598","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["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.","Validate ag.corridor.GetPath().Count > 0 before relying on the agent for path requests.","Re-add or reset the agent if its corridor becomes empty due to navmesh changes."],"exampleFix":"// before\ncrowd.RequestMoveTarget(agent, targetRef, targetPos);\n\n// after — ensure corridor is populated\nif (agent.corridor.GetPath().Count == 0)\n{\n    // re-initialize agent position on navmesh first\n    crowd.RemoveAgent(agent);\n    agent = crowd.AddAgent(validPos, agentParams);\n}\ncrowd.RequestMoveTarget(agent, targetRef, targetPos);","handlingStrategy":"validation","validationCode":"if (agent.corridor.GetPath().Count == 0) { Log.Error(\"agent corridor empty, re-initialize before move target\"); return; }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Initialize each crowd agent position on a valid navmesh poly before requesting targets.","Check corridor path count before relying on it.","Reset/re-add agents whose corridor becomes empty."],"tags":["recast","detour","crowd","navigation","pathfinding"],"backgroundTag":null,"analyzedSha":"5cab01f7a8bee5f49f4781eebe9e2b1c6d7ebe0f","analyzedAt":"2026-08-13T21:10:40.377Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}