{
  "id": "unity/terrain-collider-mismatch",
  "signature": "ArgumentException: TerrainCollider does not support negative terrain height values",
  "signature_zh": "参数异常：地形碰撞器不支持负的地形高度值",
  "regex": "ArgumentException: TerrainCollider does not support negative terrain height values",
  "domain": "unity",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "TerrainData heightmap contains negative values, which TerrainCollider cannot process.",
  "root_cause_type": "generic",
  "root_cause_zh": "地形数据高度图包含负值，地形碰撞器无法处理。",
  "versions": [
    {
      "version": "2022.3.0f1",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "2023.1.0b10",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "2021.3.20f1",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Resetting TerrainCollider component in Inspector",
      "why_fails": "The issue is in TerrainData, not the collider component; resetting doesn't modify heightmap.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "Deleting and recreating the terrain",
      "why_fails": "Loses all terrain data and work; the root cause (negative heights) must be fixed in data.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "Setting TerrainCollider.enabled = false then true",
      "why_fails": "Only toggles collider state, does not address invalid height values.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "In Editor, select Terrain, open Terrain Settings, click 'Flatten' button to set all heights to 0, then re-paint heights with positive values. Alternatively, use script: TerrainData.SetHeights(0, 0, Mathf.Max(0, heights)).",
      "success_rate": 0.85,
      "how": "In Editor, select Terrain, open Terrain Settings, click 'Flatten' button to set all heights to 0, then re-paint heights with positive values. Alternatively, use script: TerrainData.SetHeights(0, 0, Mathf.Max(0, heights)).",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use a script to clamp negative heights: var heights = terrainData.GetHeights(0, 0, terrainData.heightmapResolution, terrainData.heightmapResolution); for (int y = 0; y < heights.GetLength(0); y++) for (int x = 0; x < heights.GetLength(1); x++) heights[y,x] = Mathf.Max(0.01f, heights[y,x]); terrainData.SetHeights(0, 0, heights);",
      "success_rate": 0.9,
      "how": "Use a script to clamp negative heights: var heights = terrainData.GetHeights(0, 0, terrainData.heightmapResolution, terrainData.heightmapResolution); for (int y = 0; y < heights.GetLength(0); y++) for (int x = 0; x < heights.GetLength(1); x++) heights[y,x] = Mathf.Max(0.01f, heights[y,x]); terrainData.SetHeights(0, 0, heights);",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "In Editor, select Terrain, open Terrain Settings, click 'Flatten' button to set all heights to 0, then re-paint heights with positive values. Alternatively, use script: TerrainData.SetHeights(0, 0, Mathf.Max(0, heights)).",
    "Use a script to clamp negative heights: var heights = terrainData.GetHeights(0, 0, terrainData.heightmapResolution, terrainData.heightmapResolution); for (int y = 0; y < heights.GetLength(0); y++) for (int x = 0; x < heights.GetLength(1); x++) heights[y,x] = Mathf.Max(0.01f, heights[y,x]); terrainData.SetHeights(0, 0, heights);"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://docs.unity3d.com/Manual/class-TerrainCollider.html",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.85,
  "fix_success_rate": 0.88,
  "resolvable": "true",
  "first_seen": "2023-03-15",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}