- Home /
Question by
chinapdyh · Aug 21, 2014 at 09:26 PM ·
terrainterraindata
Create Terrain withTerrainData
In a project I have to create Terrain by script,I used the TerrainData interface.For some reason the Terrain's width and height can not be equal.The code like this:
private TerrainData terrain;
terrain = new TerrainData ();
terrain.heightmapResolution = cDepthWidth+1;
terrain.size = new Vector3 (cDepthWidth,128,cDepthHeightAdjust);
ter = Terrain.CreateTerrainGameObject (terrain);
terArr = new float[cDepthHeightAdjust,cDepthWidth];
terrain.SetHeights (0,0,terArr);
But when I had succeed create the Terrain. I found the width and the height of the Terrain was right.But the array of heightmap (terArr) seemed be compressed. The height/width ratio of the heightmap was incorrect.The width of the heightmap has been compressed. I do not know whatreason causes. Is there something wrong in my code?
Comment