Making caves in the terrain - again, but this time with scripts

Hello everybody,

this is yet another question concerning caves in the terrain. I have found out so far that unity doesn't support this and I would need to hack around with creating a separate mesh for the cave, attaching it to the terrain, adding a shader to the entrance that stops the terrain from being rendered and add a trigger which disables collision detection to let objects actually pass through the hole.

Now, my question is: how do I do all of that from within a script? There are some (deep) holes/caves that I want to generate automatically.

So, for the collision detection: I would like to just create a trigger on the entrance to the hole, but how do I add a trigger to the terrain? I don't see any addTrigger or similar methods in Terrain, TerrainData or RigidBody. Same goes for adding the shader - I have found out that zou can pass one in the constructor to a RigidBody (so I guess I can do the same for a Terrain), but I haven't found out how to add one to the existing Terrain (and anyways, I would need more than just one)...

Are there any examples that would show something in that direction? Not neccessarily with holes or caves, just the techniques needed here.

Thanks a lot in advance!

you can also use the tutorial on
http://www.smokymonkeys.com/kyrill/index.asp?direct=22

use google translate to translate it.

There’s a plugin for this on the Asset Store: Terrain Hole System

Description: “This Unity extension lets you make holes in your terrain that characters and other objects can go through.”

More information can be found on the forum thread.