0
0
Unityframework~10 mins

NavMesh baking 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 start baking the NavMesh in Unity.

Unity
NavMeshSurface surface = GetComponent<NavMeshSurface>();
surface.[1]();
Drag options to blanks, or click blank then click option'
ABuildNavMesh
BGenerateNavMesh
CStartBake
DBake
Attempts:
3 left
💡 Hint
Common Mistakes
Using BuildNavMesh() which does not exist on NavMeshSurface.
Trying to call GenerateNavMesh() which is not a valid method.
2fill in blank
medium

Complete 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'
AGetComponent
BFindObjectOfType
CAddComponent
DGetNavMeshSurface
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.
3fill in blank
hard

Fix 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'
ABakeAsync
BBake
CStartBake
DBuildNavMesh
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.
4fill in blank
hard

Fill 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'
ABuildSources
BCollectSources
CGatherSources
DGetSources
E1
F0
G2
H3
Attempts:
3 left
💡 Hint
Common Mistakes
Using BuildSources or GatherSources which do not exist.
Using the wrong area number which filters out all sources.
5fill in blank
hard

Fill 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'
A1
BWalkable
Cnew Bounds(Vector3.zero, new Vector3(50, 50, 50))
D0
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.