So in the screen you see i have aligned some sprite objects to the terrain, now in this bit of code i try to modify the terrain heights based on position of my guide dots.
var TD = Map.terrainData;
var W = TD.heightmapWidth;
var H = TD.heightmapHeight;
Debug.Log(W);
Debug.Log(H);
var TH = TD.GetHeights(0, 0, W, H);
for (int i = 0; i < TilePositions.Count; i++) // I think that all the positions exist so therefor :
{
int X = (int)TilePositions[i].x;
int Z = (int)TilePositions[i].z;
if (Random.Range(0, 4) == 1) // Just basic randomization of height
{
TH[X, Z] = 0.001f;
}
else
TH[X, Z] = 0; // One of these XZ does not exist
}
TD.SetHeights(0, 0, TH);
I not sure i understand what exactly i am doing, or waht i am missing. But it does work for some coordinates and then stops working before covering the map.
If you can help thank you
