Destroyable terrain?

Hi

I am wonder how to make a script that I can use to destroy terrain in-game. So if I press a button terrain will be removed at the desired location. Let’s take an example, I want to have a station that mines something. And when I press a button then It starts to dig a hole right next to the station. And every second it gets deeper. I know how to program, but I do not know how to make a command that will destroy terrain. So you don’t have to write a lot of code that doesn’t have anything to do with terrain.

All tips are welcomed!

2 Answers

2

You can get the TerrainData from your Terrain from script, and edit it directly. Using GetHeights and then SetHeights with the difference. I didn’t test it, but I would presume that performances can be bad if you do this often, say every frame.

But note that you will only be able to dig vertically. Not creating caverns.

How do I access it? How do I access the TerrainData? Can I just use it in a script and add it to the terrain?

This may help, http://unity3d.com/support/documentation/ScriptReference/TerrainData.html