> 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/package-elements/components/nav-mesh-baker-legacy.md).

# Nav Mesh Baker (Legacy)

> Note: as of 1.3.0 this component has been removed. See the [Upgrade Guide ](/megacrush-unity-assets/runtime-navmesh-baker/runtime-navmesh-baker-user-manual/getting-started/whats-new-upgrade-guide.md)for more information

The **NavMeshBaker** component is a **backwards-compatible wrapper** provided for projects that used earlier versions of the Runtime NavMesh Baker. It preserves the original workflow (attach a single component, set a player, press Play) while internally delegating to the new `NavMeshBakerService`.

> **Note:** For new projects, we recommend using the **NavMeshBakerService + NavMeshBakeProfile** workflow. This component is primarily for **compatibility and quick setup**.

***

### Overview

* Ensures a `NavMeshBakerService` exists in the scene.
* Tracks a **Player (Center Target)** object, usually the player character or camera.
* Rebakes the local navmesh around the target either **automatically** or on-demand.
* Forwards bake completion events through the legacy `onNavMeshUpdated` callback for existing scripts.

***

### Inspector Reference

#### Properties

* **Auto Initialize (bool)**\
  If enabled, the component automatically calls `Init()` at scene load.
* **Player (Center Target) (GameObject)**\
  The object to keep the navmesh centered around. If left empty, the **Main Camera** is used.
* **Auto Update NavMesh (bool)**\
  If enabled, the service will poll automatically and trigger rebakes when needed. If disabled, you must call `Bake()` manually.

***

#### Buttons

* **Set Player = Main Camera**\
  Quickly assign the active camera as the center target.
* **Find/Create Service**\
  Ensures a `NavMeshBakerService` exists in the scene. Creates one if missing.
* **Open Service**\
  Pings the existing service GameObject in the hierarchy for inspection.
* **Bake Once**\
  Immediately queues a one-time navmesh bake around the current center target.
* **Clear All** *(Editor-only)*\
  Removes all navmesh data. Useful for previewing or resetting navmesh data during development.

***

### API (Legacy)

These methods are retained for compatibility with earlier versions of the package:

* **`Init()`**\
  Creates or finds a `NavMeshBakerService` in the scene and assigns the center target.
* **`Bake()`**\
  Queues a one-off bake around the current center target.
* **`SetActivePlayer(GameObject newPlayer)`**\
  Switches the tracked player/center target.
* **`onNavMeshUpdated (event)`**\
  Event fired when a navmesh bake finishes.\
  \&#xNAN;*(New equivalents are in `NavMeshBakerService`: `OnBakeStarted`, `OnBakeCompleted`, `OnBakeFailed`.)*

***

### When to Use

* Use `NavMeshBaker` if you’re upgrading an older project and want **drop-in compatibility**.
* For new projects, prefer the **service-based workflow** (`NavMeshBakerService + NavMeshBakeProfile`) for full control, flexibility, and future-proofing.
