0
0
Unityframework~10 mins

Terrain system basics in Unity - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a new Terrain object in Unity.

Unity
Terrain terrain = Terrain.[1]();
Drag options to blanks, or click blank then click option'
ACreateTerrain
BNewTerrain
CCreateTerrainGameObject
DCreate
Attempts:
3 left
💡 Hint
Common Mistakes
Using a method that does not exist like CreateTerrain or NewTerrain.
Trying to instantiate Terrain directly without using the correct method.
2fill in blank
medium

Complete the code to set the heightmap resolution of a TerrainData object.

Unity
terrain.terrainData.[1] = 513;
Drag options to blanks, or click blank then click option'
AresolutionHeightmap
BheightmapResolution
CheightResolution
DheightMapSize
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect property names like heightResolution or heightMapSize.
Trying to set resolution on the Terrain object instead of TerrainData.
3fill in blank
hard

Fix the error in the code to get the Terrain component from a GameObject.

Unity
Terrain terrain = gameObject.[1]<Terrain>();
Drag options to blanks, or click blank then click option'
AGetComponent
BFindComponent
CGetTerrain
DFindObjectOfType
Attempts:
3 left
💡 Hint
Common Mistakes
Using FindComponent which does not exist.
Using FindObjectOfType which searches the whole scene, not just the GameObject.
4fill in blank
hard

Fill both blanks to set the size of the Terrain in Unity.

Unity
terrain.terrainData.size = new Vector3([1], [2], 500);
Drag options to blanks, or click blank then click option'
A1000
Bterrain.terrainData.size.y
C600
Dterrain.terrainData.heightmapResolution
Attempts:
3 left
💡 Hint
Common Mistakes
Using heightmapResolution for size values.
Mixing up the order of Vector3 parameters.
5fill in blank
hard

Fill all three blanks to create a heightmap array and assign it to the TerrainData.

Unity
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);
Drag options to blanks, or click blank then click option'
A513
B512
Cheights.GetLength(0)
Dterrain.terrainData.heightmapResolution
Attempts:
3 left
💡 Hint
Common Mistakes
Using hardcoded numbers that don't match the terrain's resolution.
Using the wrong dimension for loops causing index errors.