Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to create a new Mesh object.
Unity
Mesh mesh = new [1](); Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using MeshRenderer instead of Mesh
Trying to create a GameObject instead of a Mesh
✗ Incorrect
We create a new Mesh by calling new Mesh(). MeshRenderer is a component, not a mesh object.
2fill in blank
mediumComplete the code to assign the mesh to the MeshFilter component.
Unity
GetComponent<MeshFilter>().[1] = mesh; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Assigning to material instead of mesh
Using renderer property which belongs to MeshRenderer
✗ Incorrect
The MeshFilter component has a mesh property where we assign the Mesh object.
3fill in blank
hardFix the error in the code to add a MeshRenderer component.
Unity
gameObject.AddComponent<[1]>(); Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Adding MeshFilter instead of MeshRenderer
Trying to add Mesh or Material as a component
✗ Incorrect
To render the mesh, we add a MeshRenderer component to the GameObject.
4fill in blank
hardFill all three blanks to create vertices and assign them to the mesh.
Unity
Vector3[] vertices = new Vector3[] { [1], [2], [3] };
mesh.vertices = vertices; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using the same vertex twice
Using invalid Vector3 syntax
✗ Incorrect
Vertices define points in 3D space. Here, we create three points at (0,0,0), (1,0,0), and (0,1,0).
5fill in blank
hardFill all three blanks to define triangles for the mesh.
Unity
int[] triangles = new int[] { [1], [2], [3] };
mesh.triangles = triangles; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using indices out of range
Not providing exactly three indices
✗ Incorrect
Triangles are defined by indices of vertices. Here, the triangle uses vertices 0, 1, and 2.