I have a small scene, consisting of a 128x128x128 terrain. Those are the dimensions and height. All I want to do is be able to modify the terrain height in a sensible and clear way.
I execute this code, every time you press “T”.
// Get the height at 0,0
float height = Terrain.activeTerrain.terrainData.GetHeight(0, 0);
Debug.Log(height);
// Increase it by .001
Terrain.activeTerrain.terrainData.SetHeights(0,0,new[,]{{height + 0.001f}});
// Print the new height
height = Terrain.activeTerrain.terrainData.GetHeight(0, 0);
Debug.Log(height);
Here is the debug output for the first height increase:
0 (the initial height, which is correct)
0.1289141 (? I increased it by .001…)???
The second time I do this, I get:
.1289141 ok correct, I guess…that was the previous value
16.62992 -??? What the heck!? How/WHY did it jump from .128 to 16.62
The unity documentation is pretty much useless on this matter.
If my terrain height has a max height of 100 meters, I should be able to increase the height at a given point by 0.01 to raise it a meter, right? Is the height increase being treated as a multiplier??
Can someone shed some light on this situation?