Game Development

How to use Navmesh in 2D projects

Step 1: Obtain NavMesh Plus

Begin by downloading NavMesh Plus from its GitHub repository here. Once downloaded, unzip the NavMesh Plus archive.

Step 2: Integration with Your Project

Copy the entire “Navmesh components” folder from the unzipped NavMesh Plus package into the “Assets” folder of your Unity project.

Step 3: Setting Up the Ground

  1. Create a square 2D sprite in your Unity scene to serve as the ground. Adjust its size as needed, and feel free to change its color. To enhance clarity, rename this sprite to “ground.”
  2. Add a Navigation Modifier component to the “ground” object.

Step 4: Introducing Obstacles

  1. Populate your scene with various obstacles. Ensure these obstacles are visually distinguishable from the ground by assigning them a layer value of 1.
  2. For each obstacle, attach a Navigation Modifier component. Enable the “Override Area” option and choose “Not Walkable” from the Area dropdown.

Step 5: Creating a NavmeshSurface

  1. Insert a new empty GameObject into your scene and give it a suitable name, such as “NavmeshSurface.”
  2. Add two components to the “NavmeshSurface” GameObject: “Navigation CollectSources2D” and “Navigation Surface.” When adding “Navigation CollectSources2D,” select the option that includes the “Rotate Surface to XY” feature.

Step 6: Configuring NavmeshSurface

  1. Click the “Rotate Surface to XY” button within the “Navigation CollectSources2D” component.
  2. In the “Navigation Surface” component, press the “Bake” button to generate the navmesh.

Step 7: Completion

Congratulations! You have successfully set up a basic Unity 2D project with NavMesh. Your navigation mesh is now ready for use, allowing characters and objects to navigate around obstacles intelligently.

Avatar photo

SayedTurzo

Hi, I'm Sayed Turzo, the founder of Endless Existence and a passionate game developer focused on Roblox, Unity, programming, AI, and game design.I create practical, beginner-friendly tutorials that help aspiring developers build real games using Roblox Studio, Unity, Luau, C#, and modern game development workflows.My goal is to make game development easier to learn through step-by-step guides, best practices, optimization tips, and real-world development experience.Whether you're creating your first Roblox game or building advanced Unity projects, Endless Existence is here to help you become a better game developer.

View Author Profile →

Continue Your Game Development Journey

Explore more practical tutorials on Roblox, Unity, C#, Luau, AI, and Game Development.

One comment

Leave a Reply

Your email address will not be published. Required fields are marked *