Game development  - 
Anyone know of any examples or tutorials on how to modify terrain by code? I know its possible...
Patrick Q's profile photoChad Jenkins's profile photo
I suppose it depends on exactly what it is you want to do with the terrain. I've not been able to find full tutorials. However, I do recall seeing some information on Unity Answers that seemed useful.

Hopefully that will give you a decent starting point. The general procedure appears to be to get the array of heights using terrainData.GetHeights. Alter them as you wish, and save it back using terrainData.SetHeights.
Awesome, thanks! My intent is to dynamically generate terrain using Perlin noise. I used to do it in Aviary's node-based image effects tool, but I'd like to figure out how to do it at runtime within Unity.
Ah, okay. You may want to have a look at the port of LibNoise to Unity then. Once you've generated an appropriate array of height values, you should be able to just save them back to the terrain data structure. You can even use a good noise library to ensure the edge of your cells are seamless. (If you want to tile terrains for super massive areas)

Libnoise also has some excellent tutorials on creating noise based terrain features, if you're interested. Even though it's c++ most of the concepts can be easily ported over to C# or another language.
Add a comment...