{
  "id": "unity/physics-query-hits-self",
  "signature": "InvalidOperationException: Physics.Raycast query may hit the same collider multiple times if the collider is not set to QueryTriggerInteraction.Ignore",
  "signature_zh": "InvalidOperationException: 如果未将碰撞器设置为 QueryTriggerInteraction.Ignore，Physics.Raycast 查询可能会多次击中同一碰撞器",
  "regex": "InvalidOperationException: Physics\\.Raycast query may hit the same collider multiple times if the collider is not set to QueryTriggerInteraction\\.Ignore",
  "domain": "unity",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "A Physics.RaycastNonAlloc call returns duplicate hits when the collider is a trigger and QueryTriggerInteraction.UseGlobal is set, causing array overflow.",
  "root_cause_type": "generic",
  "root_cause_zh": "当碰撞器是触发器且 QueryTriggerInteraction.UseGlobal 设置时，Physics.RaycastNonAlloc 调用会返回重复命中，导致数组溢出。",
  "versions": [
    {
      "version": "Unity 2022.3",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Unity 2023.1",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Unity 2023.2",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Unity 6000.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "The error occurs because the same collider is hit multiple times, not because the buffer is too small.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Changing isTrigger alters collision behavior and may not be acceptable for the game design.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Set QueryTriggerInteraction.Ignore in the RaycastNonAlloc call to ignore trigger colliders.",
      "success_rate": 0.95,
      "how": "Set QueryTriggerInteraction.Ignore in the RaycastNonAlloc call to ignore trigger colliders.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use Physics.RaycastAll instead and deduplicate hits by collider instance ID.",
      "success_rate": 0.92,
      "how": "Use Physics.RaycastAll instead and deduplicate hits by collider instance ID.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Set QueryTriggerInteraction.Ignore in the RaycastNonAlloc call to ignore trigger colliders.",
    "Use Physics.RaycastAll instead and deduplicate hits by collider instance ID."
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://docs.unity3d.com/ScriptReference/Physics.RaycastNonAlloc.html",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.85,
  "fix_success_rate": 0.91,
  "resolvable": "true",
  "first_seen": "2024-06-18",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}