Hello,
I would like to know if it is possible to change the Terrain just on a certain area around the player f.e. in a radius of 5f. That´s what I have so far ( this works global). I got for each texture 2 variants loaded on the Terrain. They are allways next to each other so I can just give the TextureNumber and add one on it to get the Texture I want to change it to. The position of the Texture from the original should stay the same.
public void UpdateTerrainTexture(int textureNumberFrom)
{
//get current paint mask
float[, ,] alphas = terrainData.GetAlphamaps(0, 0, terrainData.alphamapWidth, terrainData.alphamapHeight);
// make sure every grid on the terrain is modified
for (int i = 0; i < terrainData.alphamapWidth; i++)
{
for (int j = 0; j < terrainData.alphamapHeight; j++)
{
//for each point of mask do:
//paint all from old texture to new texture (saving already painted in new texture)
alphas[i, j, textureNumberFrom+1] = Mathf.Max(alphas[i, j, textureNumberFrom], alphas[i, j, textureNumberFrom+1]);
//set old texture mask to zero
alphas[i, j, textureNumberFrom] = 0f;
}
}
// apply the new alpha
terrainData.SetAlphamaps(0, 0, alphas);
}