I’m trying to figure out how to bake navmesh at runtime.
I installed the package AI Navigation version 1.0.0-exp4, and it says it’s installed.
When I try:
GetComponent()
The type or namespace name ‘NavMeshSurface’ could not be found (are you missing a using directive or an assembly reference?)
When I try:
using UnityEngine.AI.Navigation
The type or namespace name ‘Navigation’ does not exist in the namespace ‘UnityEngine.AI’ (are you missing an assembly reference?)
In which namespace can I find this class if it’s not in AI ?
That is AMAZING… not two hours ago I became familiar with this so-called Component Workflow myself. Until today I had no idea it existed.
Here was the Lurking Ninja who turned me onto it. It is external code that you must install in your project. It might be installable by Package Manager too, but I just hand-installed it from the repository:
I’m sorry I’m not sure I understand what I should look for in the post you cited, it’s about the volume not having effect on anything other than NavMeshSurface right ?
My problem is that I have the package installed, it’s in my package.json, unity says it’s installed, but this class is not reachable, and I don’t understand why, in every example I look there’s no specific import for this class, and yet not there, although I can add a NavMeshSurface from the menu so the component is here.
I think what is happening is you have com.unity.ai.navigation, which USED to be built-in but now is a package.
But you still ALSO need to get the NavMeshComponents , which has these classes:
./Scripts/NavMeshModifierVolume.cs
./Scripts/NavMeshSurface.cs
./Scripts/NavMeshModifier.cs
./Editor/NavMeshModifierEditor.cs
./Editor/NavMeshSurfaceEditor.cs
./Editor/NavMeshLinkEditor.cs
./Editor/NavMeshComponentsGUIUtility.cs
./Editor/NavMeshModifierVolumeEditor.cs```
If you don't see ANY of the above classes, you still need the NavMeshComponents stuff, separately.
Ok so I pick the Editor and Scripts folder and it seems okay now everything is shouting that the object don’t allow read access when I try to build the nav mesh so there is definitely something going on.
Thank you for your answers.
Who is complaining about that? ALSO: make sure you save the scene first, and when you’re making a standard navmesh and save it, it makes a folder named the same as your scene right there. Perhaps this is relying on you first baking a “Regular” navmesh to create that folder??
I’ve made so many super-hyper-fast micro nav scenes today while exploring the subject in that other thread, I think I made four or five different versions in like half an hour. It’s pretty quick when you remember the bits:
So it was the static of the prefab, by unchecking the static on the prefab that are instanciated via scripts I don’t get the readonly error.
I have to go read what this static mean
EDIT:
So it wasn’t that i don’t know what it is yet.
Interesting. I’ve never marked a prefab static… I leave my static stuff in scene, and generally anything I put in a scene once, I won’t mark static.
All static stuff I tend to put under a single GameObject, then at the end of an editing session, clear all static flags (select all, uncheck, children), then re-set ONLY the static I want, all children.
There is a LOT of different static meanings: lightmaps, navigation, occlusion, etc., each for a different purpose.
Set the NavMeshSurface to Physics Colliders instead of Render Meshes.
I also disabled the Static Batching in the Project Settings / Player
I’m not sure every step in necessary and I don’t really understand what are the consequences of doing this but if another person comes around and get stuck with the same issue at least these are some possible fixes.
I came across the same problem today. So it’s been a year and the classes still have not been added to the experimental package?
This seems like a supreme oversight to be able to install a package, but that it requires you to download a portion of a repository that claims IN ITS README:
“This project is now developed as part of the AI Navigation package. Please add that package to your project in order to continue building the NavMesh using these components and to get access to newer versions.”
The readme explicitly says that the repository is available for older versions of unity. Since I am NOT using an older version of Unity I would expect all the necessary components and scripts to be available.
Might be a year late, but I’ve got your answer,
You have to use the Unity.AI.Navigation namespace! Gotta admit it’s odd since it used to be under UnityEngine.AI.Navigation.
I ran into this same issue when trying to import Digger Pro into my game that I had already had a navmesh and stuff running. Bringing in digger pro made my console error:
The type or namespace name ‘NavMeshSurface’ could not be found (are you missing a using directive or an assembly reference?)
I tried many of the solutions above and ultimately what worked was going into the file that had a compilation error, (DiggerNavMeshRuntime), and adding the following using statement at the bottom of the rest of the using statements:
using Unity.AI.Navigation;
This was strange because I had felt that I had removed this line previously to fix the issue and just added it back in because it was suggested my visual studio. Now my game runs again. I have no idea what is going on and I hope this helps someone.
Why don’t people use VS automatic namespace import quick action? just set your cursor where the type is, press Alt+Enter (or Ctrl+.) and VS will suggest which namespace to import, hit Enter and you’re done.