Home

Awesome

unity-navgen

Tools for working with Unity's NavMeshComponents and generating navmesh: link generation, mesh cleanup, etc

Default NavMesh GenerationUsing NavLinkGenerator's Bake Links and Interior Volumes
Default navmesh generationHiding cube platform to show navmesh island inside
After running Bake Links in NavLinkGeneratorHiding cube platform to show there's no navmesh island inside

NavLinkGenerator

NavLinkGenerator is an asset for generating NavMeshLinks across gaps in your navmesh. It also serves as the central hub for navgen.

NavLinkGenerator

NavLinkGenerator is a ScriptableObject -- so you need to create one to start using it (Assets > Create > Navigation > NavLinkGenerator). The asset contains settings and buttons for generating links.

NavNonWalkableCollection

The "Create Interior Volumes" button in NavLinkGenerator creates a NavNonWalkableCollection which tracks the volumes so they can be rebuilt. Remove a volume from this component's list to prevent it from being modified.

NavMeshAreas

You can assign enum values from UnityEngine.AI.NavMeshAreas to NavMeshAgent's AreaMask and UnityEngine.AI.NavMeshAreaIndex to area indexes in NavMeshSurface, NavMeshLink, NavMeshModifierVolume, etc. These enums are automatically updated from the areas defined in Navigation (Window > AI > Navigation).

NavMeshAreas generates two enums that look something like this:

// NavMeshAgent uses AreaMask.
[Flags]
public enum NavMeshAreas
{
    None = 0,
    Walkable = 1, NotWalkable = 2, Jump = 4, Climb = 8, Blocked = 16, Hole = 32, Edge = 64, Fall = 128, New1 = 256, Stuff = 512, 
    All = ~0,
}

// NavMeshSurface, NavMeshLink, NavMeshModifierVolume, etc. use indexes.
public enum NavMeshAreaIndex
{
    Walkable = 0, NotWalkable = 1, Jump = 2, Climb = 3, Blocked = 4, Hole = 5, Edge = 6, Fall = 7, New1 = 8, Stuff = 9, 
}

Example

See the example branch for a demonstration project.

Installation

  1. Install Unity NavMeshComponents from github.

  2. Copy the code to your project or add a dependency to your manifest.json to install as a package:

    "com.github.idbrii.unity-navgen": "https://github.com/idbrii/unity-navgen.git#latest-release",

Alternatives

Credits

This project includes UnityNavMeshAreas Copyright (c) 2018 jeffvella.