- Home /
How do you apply texture to terrain based on height with scripts?
I would have assumed you could just do something like:
float[, ,] splatmapData = new float[Terrain.activeTerrain.terrainData.alphamapWidth, Terrain.activeTerrain.terrainData.alphamapHeight, Terrain.activeTerrain.terrainData.alphamapLayers];
for (int y = 0; y < Terrain.activeTerrain.terrainData.alphamapHeight; y++) {
for (int x = 0; x < Terrain.activeTerrain.terrainData.alphamapWidth; x++) {
float height = Terrain.activeTerrain.terrainData.GetHeight(x, y);
if(height > 5){
??????
}
if(height <= 5){
??????
}
Terrain.activeTerrain.terrainData.SetAlphamaps(0, 0, splatmapData);
}
}
But what code would go in for the question marks? And am i right in using alphamap instead of heightmap in the loops?
I will elaborate and specify like a mofo if you have any questions.
Your answer
Follow this Question
Related Questions
A question for someone who understands alphamaps. 0 Answers
Make a simple tree 1 Answer
SetAlphamaps with multiple terrains at runtime 1 Answer
Terrain in an RTS style game 1 Answer