Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to start baking the NavMesh in Unity.
Unity
NavMeshSurface surface = GetComponent<NavMeshSurface>();
surface.[1](); Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using BuildNavMesh() which does not exist on NavMeshSurface.
Trying to call GenerateNavMesh() which is not a valid method.
✗ Incorrect
The Bake() method starts the NavMesh baking process on the NavMeshSurface component.
2fill in blank
mediumComplete the code to assign the NavMeshSurface component before baking.
Unity
NavMeshSurface surface = [1]<NavMeshSurface>();
surface.Bake(); Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using FindObjectOfType which searches the whole scene instead of the current GameObject.
Using AddComponent which adds a new component instead of getting an existing one.
✗ Incorrect
GetComponent() gets the NavMeshSurface component attached to the same GameObject.
3fill in blank
hardFix the error in the code to bake the NavMesh asynchronously.
Unity
NavMeshSurface surface = GetComponent<NavMeshSurface>();
var bakeOperation = surface.[1]();
await bakeOperation; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using Bake() which is synchronous and does not return an awaitable.
Using StartBake() which is not a valid method.
✗ Incorrect
BakeAsync() starts baking the NavMesh asynchronously and returns an awaitable operation.
4fill in blank
hardFill both blanks to create a list of NavMesh build sources filtered by area type.
Unity
var sources = NavMeshBuilder.[1](transform, LayerMask.GetMask("Walkable")); var filtered = sources.Where(s => s.area == [2]).ToList();
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using BuildSources or GatherSources which do not exist.
Using the wrong area number which filters out all sources.
✗ Incorrect
CollectSources collects NavMesh build sources from the transform with the specified layer mask. Area 0 represents the 'Walkable' area.
5fill in blank
hardFill all three blanks to bake a NavMesh with custom build settings and sources.
Unity
NavMeshBuildSettings settings = NavMesh.GetSettingsByID([1]); List<NavMeshBuildSource> sources = NavMeshBuilder.CollectSources(transform, LayerMask.GetMask("[2]")); NavMeshData data = NavMeshBuilder.BuildNavMeshData(settings, sources, [3], transform.position, transform.rotation); NavMesh.AddNavMeshData(data);
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong settings ID which causes errors.
Using incorrect layer mask string.
Not defining bounds properly causing no NavMesh to bake.
✗ Incorrect
Settings ID 0 is the default agent type. The layer mask 'Walkable' selects walkable surfaces. The bounds define the area for baking the NavMesh.