Terrain deformer?

Hi,

I cannot find much information about deforming terrains via a script.
I’d like to do this via script…Does anyone have a sample available that will work with Unity 5, or a link to an asset even?

Try using GetHeight and SetHeights on the terrain data that you can get via Terrain.terrainData. Unity 5 terrain is still quite similar to older Unity terrains in that it relies on heightmaps. Look at the Terrain and TerrainData classes.

If you are looking for overhangs, arches, caves, or things of that nature, then unfortunately Unity terrain cannot do this. You will need to use other meshes if you want to do this with Unity terrain, otherwise, look into implementing voxel terrain (Unity doesn’t have this built in as of the time this answer was written).

If you want to raise the height of position 1,1 in the terrain heightmap by 5, then:

//Untested C#
public Terrain myTerrain;
TerrainData myTerrData;
void Awake(){
     if(myTerrain){
          myTerrData=myTerrain.terrainData;
     }
}
void ChangeTerrain(){
     float[,] section = myTerrData.GetHeights(1,1,1,1);
     foreach(float f in section){
          f +=5;
     }
     myTerrData.SetHeights(1,1,section);
}

Hope this helps!