Complete the code to create a new Terrain object in Unity.
Terrain terrain = Terrain.[1]();The method CreateTerrainGameObject() creates a new Terrain GameObject in Unity.
Complete the code to set the heightmap resolution of a TerrainData object.
terrain.terrainData.[1] = 513;
The property heightmapResolution sets the resolution of the heightmap in TerrainData.
Fix the error in the code to get the Terrain component from a GameObject.
Terrain terrain = gameObject.[1]<Terrain>();The correct method to get a component from a GameObject is GetComponent<T>().
Fill both blanks to set the size of the Terrain in Unity.
terrain.terrainData.size = new Vector3([1], [2], 500);
The size property is a Vector3 where x and z define width and length, and y defines height. We set x to 1000 and y to the current height value.
Fill all three blanks to create a heightmap array and assign it to the TerrainData.
float[,] heights = new float[[1], [2]]; for (int x = 0; x < [3]; x++) { for (int y = 0; y < [2]; y++) { heights[x, y] = 0.5f; } } terrain.terrainData.SetHeights(0, 0, heights);
The heightmap array size must match the terrain's heightmapResolution. We use terrain.terrainData.heightmapResolution for all dimensions and loop limits.