Navigation Mesh 2D

You can find my 2D Navigation Mesh Tool on the Unity Asset Store.


  • Generating 2D NavMesh using constrained Delaunay Triangulation.
  • Handling all 2D Colliders.
  • Calculate the best path to reach a destination from an agent’s position.
  • Moving the agents along the path and handling dynamic obstacles avoidance.

Getting Started

  •  Add the “NavMeshSurface2D” component on a game object to create a new NavMesh Surface.
  • Click on the “Build NavMesh2D” button to generate the NavMeshSurface.
  • Click on the “Clear NavMesh2D” button to destroy the existing NavMesh.

NavMeshSurface2D Settings

  • Agent Radius: Radius used to build the NavMesh.
  • Use Children: if this toggle is set to false, the NavMesh will be built with every collider in the scene, otherwise, it will only use the children colliders of the game object.
  • Include Layers: The Colliders included in this layer will be used to build the NavMesh2D, otherwise, they will be excluded.
  • Bounds:
    • Center: Center of the bounds
    • Size: Size of the bounds
  • Edges Divisions: Number of edges subdivisions for NavMesh Surface 2D boundaries.

Agent Settings

  •  Speed: Agent’s speed.
  • Avoidance Force: Force at which the agent will avoid dynamic obstacles.
  • Steer Force: Force at which the agent will come back on the path.
  • Avoidance Layer: Layers of the obstacles that will be avoided by the agent.
    • Be careful: Do not include the layers used in the field “Include Layers” of the NavMeshSurface2D

How to make the agent move to a destination?

  • Call the method “SetDestination(Vector2 destination)” on the agent.
    If the agent and the destination are on the same NavMesh2D, the agent will move along the path that reaches the destination according to the NavMesh points.
  • Call the Method “StopAgent()” to stop the agent before he reaches the end of the path.