- Home /
SetHeights to a Negative
I'm creating a procedurally generated landscape. I can use the SetHeights function to increase the height of the terrain, creating mountains and ridges. I want to also create depressions in the terrain, but unfortunately SetHeights isn't accepting negative numbers for the heights array. For instance, in SetHeights(x,y,z[,])--if z has any negative numbers in it, they do not affect the heightmap.
I suspect this is because the heights array is suppose to be populated with numbers in the range of 0 to 1. If that's the case, how do I go about creating a depression in the terrain?
Answer by Eric5h5 · Apr 01, 2012 at 12:58 AM
You just make the baseline height something above 0. If the baseline is .5, then anything above that is raised and anything below it is a depression.
Thanks for the quick response! How do you set the baseline height? I'm looking through the TerrainData functions and variables, and I can't seem to find it there.
It's nothing you set, it's just something you assume. If you decide "O$$anonymous$$, the baseline should be .5", then it's .5.
This might not be what you meant, but I've found a solution. First, I set the whole heights array to .5, and then after that I set the elevations to floats greater than .5 and depressions to floats lower than .5. Works like a charm!