docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Build a HeightMesh for Accurate Character Placement

    Use a HeightMesh to place your character more accurately on walkable surfaces during navigation.

    During navigation, the NavMesh Agent is constrained on the surface of the NavMesh. Since the NavMesh is an approximation of the walkable space, some features are evened out when the NavMesh is built. For example, stairs may appear as a slope in the NavMesh. If your game requires accurate placement of the agent, you can either add a HeightMesh to your NavMesh, or build a HeightMesh when you bake the NavMesh.

    Note

    It takes extra memory and runtime processing to build a HeightMesh, therefore, it will take longer to bake the NavMesh.

    To add a HeightMesh to your NavMesh:

    1. Open your scene in the Editor.
    2. Select the scene geometry or GameObject that contains your NavMesh.
    3. In the Inspector, expand the NavMesh Surface component, if necessary.
    4. In the NavMesh Surface component, expand the Advanced section, then select Build Height Mesh.
    5. When you are finished, click Bake.
      The NavMesh is generated and displayed as a blue overlay and the HeightMesh as a pink overlay.

    To build a HeightMesh when you bake the NavMesh:

    1. Follow the instructions to Create a NavMesh.
    2. In the NavMesh Surface component, select Build Height Mesh.
    3. When you are finished, click Bake.
      The NavMesh is generated and displayed as a blue overlay and the HeightMesh as a pink overlay.

    HeightMesh example

    Additional resources

    • Create a NavMesh
    • NavMesh Surface component reference
    • Sample 8 - Heightmesh
    In This Article
    Back to top
    Copyright © 2025 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)