# ArgumentException: TerrainCollider does not support negative terrain height values

- **ID:** `unity/terrain-collider-mismatch`
- **Domain:** unity
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 88%

## Root Cause

TerrainData heightmap contains negative values, which TerrainCollider cannot process.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 2022.3.0f1 | active | — | — |
| 2023.1.0b10 | active | — | — |
| 2021.3.20f1 | active | — | — |

## Workarounds

1. **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)).** (85% success)
   ```
   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)).
   ```
2. **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);** (90% success)
   ```
   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);
   ```

## Dead Ends

- **Resetting TerrainCollider component in Inspector** — The issue is in TerrainData, not the collider component; resetting doesn't modify heightmap. (70% fail)
- **Deleting and recreating the terrain** — Loses all terrain data and work; the root cause (negative heights) must be fixed in data. (90% fail)
- **Setting TerrainCollider.enabled = false then true** — Only toggles collider state, does not address invalid height values. (80% fail)
