Digging Holes into Unity3D Terrains

You are here

That’s gonna be a short post, because all you need to know is over on Robert’s1 blog:

Say you’re making a Unity game that takes place in a large landscape dotted with windmills, and some of these windmills have tunnels that lead underground. But in Unity, the terrain collider is generated from heightmap data: it’s essentially one giant bumpy plane. You can’t punch holes in it.

Can we hack it to achieve the same result? Yep. Here’s one way, there are two parts to it:

  1. Hiding a piece of terrain geometry with a “depth mask” shader.
  2. Disabling the collider so the player (or whatever) can pass through the hole, but collides with terrain other times.

If you need more detail,

please head over to Robert’s blog, where everything is explained. Just had to get that out there, because it seems like something other people might find useful.

  1. Who’s talk at GDC Europe I did miss because I chickened out and didn’t go … meh. ↩︎