Sorry, this seems kind of basic - are you new to programming? If so, I recommend learning C#, it is an easy language to learn- maybe take a week or two to get the basics - and you will find everything much easier if you grasp the concepts.
But to answer your questions. GetHeights does what it says - it “gets” the height values in an array. The array contains values between 0 and 1.
SetHeights is the opposite - it sets the height values. The height values are between 0 and 1 inclusive.
Here’s a link where someone asked a similar question, and contains code:
sorry im learning java and am comming along however i still do not full understand this
GetHeight (x : int, y : int) : float
This give an array of the heights of x position and y position of the terrain. Why must the number values be less than one? Are the height values a percentage of the overall height of the map?
How do i use GetHeight?
float height = Terrain.activeTerrain.terrainData.GetHeight(0, 0); // so this essentailly gives me my height value of 0,0 in float (decimal?) form
Then SetHeights sets the height values. I have no idea how to use this though.
This is an example of how someone else used it:
Terrain.activeTerrain.terrainData.SetHeights(0,0,new[,]{{height + 0.001f}});
What is the new[,] for? and the curly brackets? it says that it increases the height value by 0.001 hence the height plus that (he had previously defined height by get height.
Sorry yet thanks this is probably really basic stuff but i can’t seem to understand it!
Yes, it’s percentage based, so to get a world position from a terrain you’d use terrain.GetHeights(x,y) * terrain.size.y.
That looks like some hilarious C# trickery.
new[,] : create a new two-dimensional array
{ : containing the following
{ : somehow having two of these causes each individual element of heights to be increased by 0.001f