Nav Mesh Baker Component
Last updated
Last updated
The core of the package is the Nav Mesh Baker component. The component is shown below and as you can see, is well documented.
The TLDR for the logic for Runtime Navmesh Baker is that it will regenerate a navmesh of size ‘Nav Mesh Size’ around the ‘Player’s position every ‘Update Rate’ seconds IF the player has moved more than ‘Move Threshold’ meters in the world.
The full Runtime Navmesh Baker inspector is shown below:
To use, simply:
Create an empty game object
Add the ‘Nav Mesh Baker’ component
Adjust desired properties (documented below)
More details about each of the properties are listed below
Should the navmesh baker start running automatically when the scene loads? If set to false, you must call Init() yourself to start the baking. See NavMeshBaker API
Runtime Navmesh Baker generates a navmesh in the local area around the player. Add a reference to the player in your scene.
This variable controls how often Runtime Navmesh Baker should check if it needs to regenerate the navmesh. The value is in seconds. It is used together with the Move Threshold to determine whether the navmesh should be generated.
This variable controls how Runtime Navmesh Baker generates the navmesh. In order to optimize how frequently the navmesh is generated, you can use this variable to determine how far the player must move before we need to generate a new navmesh.
You can adjust the size of the navmesh that is generated with this property. Click ‘Bake Local Navmesh’ (see below) to preview the size of the navmesh that is generated.
You can optionally tell the Navmesh Baker to write logs to the Unity console. If unchecked (default), then no logs will be written.
If you have baked a local navmesh (see below), this button will clear the results. Note: navmeshes baked in Edit mode are temporary and will be reset when entering playmode.
Click this button to generate a dynamic navmesh in the Editor. This can be used to preview the navmesh size during development and can also be used to create a ‘pre-baked’ navmesh that will be present immediately when your scene loads.
This can be useful if you have NavMeshAgents in your scene at load time and want to avoid getting errors that they are not present on a valid navmesh (for example if you get error / warnings like Failed to create agent because there is no valid NavMesh on scene load)