> For the complete documentation index, see [llms.txt](https://megacrush.gitbook.io/megacrush-unity-assets/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://megacrush.gitbook.io/megacrush-unity-assets/runtime-navmesh-baker/runtime-navmesh-baker-user-manual/frequently-asked-questions.md).

# Frequently Asked Questions

## FAQ & Examples

This section covers common questions and provides example scripts included with the package.

***

### How do I test that runtime baking is working?

Use the included **ClickToMoveController** sample.

**Namespace**: `MegaCrush.NavmeshBaker.Sample`

1. Attach it to a GameObject with a **NavMeshAgent**.
2. At runtime, left-click in the scene to move the agent.
3. The script:
   * Subscribes to `BakerEvents.OnBakeCompleted`.
   * Waits for the first bake.
   * Warps the agent safely onto the navmesh.
   * Enables input so you can click to move.

This demonstrates the pattern:

> **Wait for bake → enable agent → call `agent.SetDestination()`.**

***

### How can I spawn agents only after a navmesh is ready?

Use the included **SpawnOnBake** sample.

**Behavior**:

* Subscribes to `BakerEvents.OnBakeCompleted`.
* When the event fires:
  * Chooses a spawn position.
  * Calls `NavMesh.SamplePosition()` to snap to valid ground.
  * Instantiates the prefab.
* If “Only Once” is enabled, it spawns only on the first bake.

**Why it’s useful**:\
Prevents errors like:

> *“Failed to create agent because there is no valid NavMesh”*

when spawning AI too early.

***

### How can I see what’s being baked in Grid mode?

Use the included **Procgen Map** sample.

**Behavior**:

* Draws gizmos for the current grid cell and surrounding rings.
* Shows which regions will be enqueued around the player.

**Why it’s useful**:

* Helps tune `cellSizeXZ`, `rings`, and `hysteresis` in your **NavMeshBakeProfile**.
* Makes it easy to align baking cells with procedural tiles or streamed chunks.

***

### Unity throws errors about “Source mesh XXX does not allow read access.”

This is a Unity engine limitation. At runtime:

* If you bake from **Render Meshes**, Unity requires mesh assets to be marked **Read/Write Enabled**.
* If you bake from **Mesh Colliders**, the same rule applies.

By default, the Runtime NavMesh Baker enforces **Physics Colliders** mode to avoid this.

#### To fix:

1. Prefer **Physics Colliders** (default).
2. If you must use **Render Meshes** or **Mesh Colliders**:
   * Select the mesh in your Project.
   * In the **Model Importer**, enable **Read/Write**.
   * Click **Apply**.

Unity docs: [Mesh.isReadable](https://docs.unity3d.com/ScriptReference/Mesh-isReadable.html)

***

### Key Tips

* Always **subscribe to `BakerEvents.OnBakeCompleted`** before enabling or spawning agents.
* Use **GridBakeVisualizer** to validate cell setup before deployment.
* For runtime spawning systems, pattern logic after **SpawnOnBake**.
* If you see *Combined Mesh (root: scene)* errors, disable **Static Batching** for geometry that contributes to runtime baking.
